namespace expiration invalidate all keys
darius1907 opened this issue · comments
Hi,
I like your library and i would like to use it in my spring boot project.
But i have noticed a wrong behaviour about namespace key.
I have set a cache with 120s ttl.
When i put the key A in cache, keys namespaceValue:A and namespace are created with expiration 120s,
after 60 sec i put the key B in the same cache and keys namespaceValue:B is created with expiration 120s.
after 60 sec namespaceValue:A and namespace keys are expired, key B has still 60s of ttl but namespace is expired so i have i cache miss.
I have solved this issue by adding set namespace key in put method of MemcachedCache class to extend ttl
@Override
public void put(Object key, Object value) {
// added to extend namespace key ttl
this.memcachedClient.set(this.memcacheCacheMetadata.namespaceKey(), this.memcacheCacheMetadata.expiration(),namespaceValue());
this.memcachedClient.set(memcachedKey(key), this.memcacheCacheMetadata.expiration(), toStoreValue(value));
}
I hope that you'll fix this issue (maybe with a more elegant solution than i do :-))
@darius1907 thank you for reporting the issue. We'll make it a top most priority of fixing the namespace expiration.
Fixed with the latest release: 1.3.1