django-simple-redis-admin: Manage redis within the django admin

It’s been a while since I talked about anything i’ve been coding. A few months ago I released Django Simple Redis Admin, which allows you to manage redis cache keys within the Django admin. Something that annoys me with other django admin packages is the requirement to add database tables for their packages. django-simple-redis-admin gets around this by making a django model on the fly. No need for tables, just plug and play. Hopefully in the future i’ll be adding some filters and speeding things up. Check out django-simple-redis-admin on my GitHub page.

Ultramemcache: python-ultramemcached and django-ultramemached-cache

A few months ago I came across a package on GitHub called Ultramemcache, which was described as “Ultra fast memcache client written in highly optimized C++ with Python bindings.”

Using Ulramemcache, I modified the common python-memcached library to use Ultramemcache, making sure it could be used as a drop in replacement. Check out python-ultramemcached on my GitHub page.

I also put together a django cache backend using Ultramemcache. This currently does not require my python-ultramemcached library. Check out django-ultramemcached-cache on my GitHub page.

phpFlickr 3.1 cache unserialize error

I came across a problem today with phpFlickr 3.1 and the way it handles its database caching. I believe it has to do with commas in the serialized data that is being inserted into the cache table. After grabbing the cache result php gave me this error in the phpFlickr library:

Notice: unserialize(): Error at offset ... phpFlickr.php

To fix this error you need to base64 encode and decode the data going into the database.

in phpFlickr modify line 144 to decode the response:

return base64_decode($result['response']);

line 177 on cache row update:

$sql = "UPDATE " . $this->cache_table . " SET response = '" . str_replace("'", "''", base64_encode($response)) . "', expiration = '" . strftime("%Y-%m-%d %H:%M:%S") . "' WHERE request = '" . $reqhash . "'";

line 180 on cache row insert:

$sql = "INSERT INTO " . $this->cache_table . " (request, response, expiration) VALUES ('$reqhash', '" . str_replace("'", "''", base64_encode($response)) . "', '" . strftime("%Y-%m-%d %H:%M:%S") . "')";

Thanks to David Walsh for his php serialize tips:
http://davidwalsh.name/php-serialize-unserialize-issues