hyperoslo / Cache

:package: Nothing but Cache.
Other
2.96k stars 335 forks source link

removeObject Doesn't remove object from memory #301

Closed Masoomeh-Heidari closed 5 months ago

Masoomeh-Heidari commented 2 years ago

Try to update cached object:

step 1: delete object using **removeObject** 
step 2: save updated object using **setObject**

Every things goes well but the problem appears when try to get data using async.object it returns old value of object. I have checked value saved on disk it is new data.

I have trace the code and figure out to get data this first check memory : public func entry(forKey key: Key) throws -> Entry<Value> { do { return try memoryStorage.entry(forKey: key) } catch { let entry = try diskStorage.entry(forKey: key) // set back to memoryStorage memoryStorage.setObject(entry.object, forKey: key, expiry: entry.expiry) return entry } }

how can remove object in first step to make sure it is removed from disk & memory?

3lvis commented 5 months ago

Closing, reason outdated issue.