判断缓存是否为空优化改为方法

This commit is contained in:
2025-01-04 11:40:50 +08:00
parent b8f0c0f5e9
commit 953b0d05ce

View File

@@ -19,7 +19,6 @@ class CACHE {
throw (new Error('请传入缓存name值:index | {name:index}'))
return
}
this._isEmpty=Object.keys(data).length>=2?false:true;
for (let i in data) {
this[i] = data[i]
const canWrite = i.slice(0, 1) !== '_'
@@ -31,12 +30,16 @@ class CACHE {
}
}
isEmpty(){
return Object.keys(this).length>=2?false:true;
}
get(key) {
return this[key]
}
set(key, val) {
this[key] = val
uni.setStorageSync(this._name, this)
this._isEmpty=false
}
clear() {
Object.keys(this).map(v => {