Say you have a list of posts with 5 categories.
When you do memcache, how should you filter out the categories?
class Post(db.Model):
title = db.StringProperty(required=True)
category = db.StringProperty()
desc = db.StringProperty()
When you do caching:
key = "allpost"
post = Post.all().order('-created')
memcache.set(key, post)
I tried the use filter on cached object. And apparent it wouldn’t work.
cached_post.filter(“category”,”one”)
Is there any function you can do it? Or do you just have to go through the pain to filter all the categories first before caching all the posts.
You can put named things in memcache and get them out again via their key as a single piece. It looks to me as if you are putting into memcache a incomplete query or model, rather then the results of a query which you could then potentially filter.
Take a look at NDB, much of the memcaching is done for you with that (not for queries however).
So you can filter on the data you get from memcache but there are no commands to do in-memcache filtering.
Have a look at the available functions: https://developers.google.com/appengine/docs/python/memcache/functions