4 ms·
This problem has been bouncing around in my head since I first started using memcache. Figuring out how to easily and correctly invalidate cache items is an int
by tlack 15y ago
This problem has been bouncing around in my head since I first started using memcache. Figuring out how to easily and correctly invalidate cache items is an interesting problem.
Perhaps instead of explicitly defining dependencies, there could be some way of modeling your cached data as some kind of set of objects which would then understand their own graph. As you can see I haven't quite figured out how it would work but this is how I've been thinking about it lately. Like a simple ORM, in some way.
Something like the following terrible psuedocode:
cached_comment(key) = new cached_item(function(key){ query("select * from comments where..")});
cached_post(key) = new cached_item(cached_comment, function(key){query("...")});
- nkohari 15y agoThis was actually my original plan, but I took the easy way out for now. :) We use MongoDB as our data store, and between the UUIDs used as primary document keys and arrays of UUIDs representing links between documents, we could (reasonably) easily determine the dependencies automatically.