Weekend Project - CloudCached
A friend and I have been bouncing around the idea of a caching system that ran on Amazon's cloud for a while now. Basically something like memcached, but without the (very real) limitations of physical memory or the need of a whole server. Sure, it's hard to beat the speed of memory-level read access, but I think the appeal of a distributed, limitless cache might outweigh the slowdown. ### Idea Provide an interface for storing/retrieving serialized data on S3 Pretty simple idea, pretty simple implementation. Thanks to the S3 interface provided by [Boto](http://code.google.com/p/boto/ "Boto rocks!"), things were a lot easier. I'm going to keep this open source under the MIT license. You can check out the code on [GitHub repository](http://github.com/mumrah/cloudcached/tree/master "CloudCached on GitHub") - please feel free to fork, improve, submit, etc. ### Overview A quick walkthrough of the code will reveal truly how simple this is. The Client class provides basic CRUD methods for interfacing with S3: __put__, __get__, __update__, __delete__. The put and update methods store a timestamp as the "expires" header for the file to keep track of cache expiration. Also these two methods write a "type" header to the meta-data so CloudCached knows how to de-serialize the file.
class Client:
"Here's the class schema"
def get(self, key)
def put(self, key, value, time_to_expire=3600, replace=False)
def update(self, key, value, time_to_expire=3600)
def delete(self, key)CloudCached Benchmarks (10 runs)
--------------------------------------------------------
Test | Average (s) | Total (s)
--------------------------------------------------------
GET integer | 0.0283360004425 | 0.283360004425
GET string (32 byte) | 0.0315794944763 | 0.315794944763
GET string (512KB) | 0.1265994787220 | 1.265994787220
PUT integer | 0.0650457143784 | 0.650457143784
PUT string (32 byte) | 0.0563205003738 | 0.563205003738
PUT string (512KB) | 0.1773290872570 | 1.773290872570
--------------------------------------------------------
