My apps:
🌱 Working on
SharedPreferences based on mmkv, compatible with getAll and change listener.
My apps:
🌱 Working on
MultiProcessListenerMMKVSharedPreferences 不用 只用 SimpleMMKVSharedPreferences 是不是也有夸进程 k v 的读取能力只是没有跨进程的数据变更的 listener 通知 ,可以这样理解吗?
Map<String, ?> all = preferences.getAll();
拿到的 value 是 ?,如果在外面想使用如何去遍历和拿到正确的类型?
Set<String> keySet = preferences.getAll().keySet();
for (String key : keySet) {
// if {
// }
}
Map<String, ?> all = preferences.getAll();
for (int i = 0; i < all.size(); i++) {
// if () {
// }
}
一般在页面上散着用是没有问题的,但是有时候想去集中管理去简化用法的时候就会产生问题详情如下:
例如下面代码我基于您的代码做了一个 KeyValueManager 的全局单例包装,put 的时候不需要再去 commit 或者 apply 。这时候全局只有一个 Editor
public void init(Context context, String sharedPreferencesName) {
mContext = context;
mPreferences = new MMKVSharedPreferencesFactory().getSharedPreferences(context, sharedPreferencesName, Context.MODE_PRIVATE);
mEditor = mPreferences.edit();
}
这时候 MMKVEdit 内的 keyValues 缓存就会越来越大,而且我每次去 commit 的时候 commitUpdate 方法就会遍历,即使我只去 commit 一个简单的 int 值。咱们的库的设计在集中管理使用的情况下也会去遍历所有的 keyValues 重新去操作 mmkv 的接口。不知道大佬有没有考虑过这个场景?有什么好的解决办法和意见吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.