Are keys deleted when memcache data expires?

I am currently working on adding memcache to an application running on GAE / J. I have a question about how production memory behaves when values โ€‹โ€‹expire if they are also deleted.

The closest I could find to answer this question: http://code.google.com/appengine/docs/java/memcache/overview.html#How_Cached_Data_Expires

I know that I cannot rely on the values โ€‹โ€‹found in memcache; and I donโ€™t do it, but what interests me is that the keys that display these values โ€‹โ€‹are also deleted.

In other words, if I do

mycache.contains("key")

Will this remain true after the value is pushed out of the cache?

Side note: do not think that it matters; but just in case, I use async memcache from memcache service and grabbed onto it like this:

MemcacheServiceFactory.getAsyncMemcacheService();

I ask about it because I am not doing typical

if(cache.get("key") == null)

I keep null values โ€‹โ€‹when they return from the data store, so I do not constantly look at the null value. And I will take care to remove the key when it can change. Therefore, just because the memcache search returns null, I'm working on the assumption that the request is actually null; but I am sure that when other queries that may change happen that the null search is deleted. This is why I use cache.contains("key") rather than cache.get("key") == null

+6
source share
1 answer

Your assumption is correct, mycache.contains("key") will return false if the value was pulled from the memcache service. This behavior is described in the Javadoc low-level Memcache interface .

+11
source

Source: https://habr.com/ru/post/901461/


All Articles