Archive for January 2010
Setting and deleting cache in Django with tags
The Django cache system is real help when you need to keep your site as fast as possible. It offers multiple back-ends and is super easy to get started using. I just wish it had the ability to tag content when you are setting it in the cache. If you could do that then you could do bulk deleting of content based on tags. One use-case that comes up again and again for me is caching paginated results. If you have blog-entry1-page1 and blog-entry1-page2 both stored in the cache and want to delete them when a new entry is added what do you do? It’s hard if not impossible you know which paged set is currently in cache and we need to know the keys in order to delete them.
I searched and searched for a solution to this problem with not much help from google. I did find this post by Eric Florenzano which is close to the approach I took, but I wanted something more generic. So I decided to add two new methods cache.set_with_tags and cache.delete_by_tags to whatever cache backend you are using. Just to note this is only useful if you intend to utilize the low-level cache framework.
Behind the scenes of EveryBlock.com
Adrian Holovaty, bad-boy YouTube guitar star (search for him, if you dare!) and co-author of the Django web framework, takes you under the hood of EveryBlock.com, a Knight Foundation News Challenge startup which rounds up local news and information, and is powered 100% by Python and Django.
And so it goes...
Hello this is my first post in my first blog, weird. I have been a hold out for a long time on this blogging stuff and to be honest I’m not really sure why. I mean I’m by no means a good writer, my thoughts are extremely random at best, and for the most part I live a normal and relatively uninteresting life. Seeing how blogging was all the rage a few years ago it’s my time to have my hand in it. I’m always late to the party, however I’m usually the last one standing attempting to drink whatever is left in fridge and clutching onto whatever remaining youth I still posses.
So please be patient with me as I attempt to share my thoughts on code, life, new music I discover, why I find certain things annoying, and whatever I feel like spewing onto the internets. With all this said I will issue the following disclaimer. I suck, suCK, SUCK at writing, grammar, spelling and generally anything evolving words. Oh well, I don’t give a shit, this is my blog dammit if you don’t like it go read one of the other 70+ million blogs on the web.






