Héllo psychok7,
On Tuesday, January 8, 2013 1:45:07 PM UTC+1, psychok7 wrote:
Hi guys, just wondering if its possible to sort a django cache? I need to add data with an auto increment id to the cache and sort it in reverse order to get it back. I no this can be easily accomplished with the normal mysql database but since the cache is faster i would like to do it there
Yes and no.
- get
- get_many
- set
- set_many
- incr
- decr
- delete
- delete_many
With those, you can do what you want, you have to set up a «schema» with cache keys that will allow you to do what you want.
Similarly you can also do this sort of things using
redis, which is also pretty fast since it's also a in memory key/value store, using higher level methods on higher level data structures like lists, sets, sorteds sets, hashes. You might as well fallback on creating your own data structures relying on existing datastructures usings
scripts.
The usecase you are discribing is not clear, why not just do the sorting with mysql, store in the cache with an expiration key the results, ids or rendered templates ?