[Answer]-Search for a key in django.core.cache

1👍

Memcached only allows you to get/set entries by their keys. You can’t iterate these entries to check something. But if your cache keys are sequential (like sess1, sess2, etc.) you can try to check for existence in a loop:

for i in range(1000):
    sess = cache.get('sess%s' % i)
    # some logic

But anyway it seems like a bad design decision. I don’t have enough information about what you’re doing but I guess that some sort of persistent storage (like database) would work nice. You can also consider http://redis.io/ which has more features than memcached but still very fast.

👤alTus

Leave a comment