Reputation: 13
Im using memcache to store a json, and it's working. But the problem is that the cache size grow if I call that line above many times:
memcache.Client.add(memcache.Client(),"searchindex",json)
So I looked at the memcache viewer and the content still the same, since Im using a key that's already on cache. But, even though the size of cache continues to increase.
Upvotes: 1
Views: 398
Reputation: 12838
First off, that's a really odd way to invoke an instance method. Normally you would do this:
memcache.Client().add("searchindex", json)
Or simply:
memcache.add("searchindex", json)
Since add
will not overwrite a key that already exists in cache, calling it repeatedly should have no impact on the behavior of your application.
Whether or not these calls increase the cache size shouldn't really be a concern. Memcache is designed to make memory available as it's needed by your application, based on a least use algorithm. Junk memory from inert should add
calls should certainly be evicted first.
Upvotes: 5