4 ms·
Python Datastructures Backed by Redis
- lethain 16y agoSeeing that Redis is a datastructure storage mechanism, I guess it shouldn't shock anyone that it maps well to existing datastructure interfaces. Maybe the more interesting aspect here is the power of having datastructure-aware datastores as opposed to trying to hide the implementation details behind (potentially) leaky abstractions.
- deepu_256 16y ago@lethain - you beauty. Nice work. The thing is - it is not surprising that redis maps well with the python DS. It is that after reading this it occurred to me how powerful having Persistent DS(Not in the Functional DS sense but in data storage sense) can simplify web programming.
- po 16y agoI can sort of see the benefit of using it as a serialization format. Use it to replace the db for some things or instead of a configuration file. It might be nicer to send it to a data store then have to write into a file... However, doesn't this turn it into the mother-of-all global variables? (Actually, if it's outside of the globe, and outside of the system, can we call them galactic variables?) With in-memory lists, the scoping is relatively well defined. It seems like the temptation to take this too far would be great.
- amix 16y agoI did something very similar a while back (redis_wrap): http://amix.dk/blog/post/19508 http://amix.dk/blog/post/19508
- fictorial 16y agoThe redis python client already uses an API that maps 1:1 with Redis which makes it simple to read the redis docs and get going. Store a dictionary: import redis r = redis.Redis() r.hmset('key', dict(foo='bar', n=42)) Store a single value in a dictionary/hash: r.hset('key', 'foo', 'buz')
- tomstuart 16y agoredis-objects does a pretty good job of this for Ruby: http://github.com/nateware/redis-objects http://github.com/nateware/redis-objects
- zitterbewegung 16y agoI wonder how hard this would be to do this for something like clojure.