About Archive Tags RSS Feed


A partial perl-implementation of Redis

11 July 2014 21:50

So recently I got into trouble running Redis on a host, because the data no-longer fits into RAM.

As an interim measure I fixed this by bumping the RAM allocated to the guest, but a real solution was needed. I figure there are three real alternatives:

  • Migrate to Postgres, MySQL, or similar.
  • Use an alternative Redis implementation.
  • Do something creative.

Looking around I found a couple of Redis-alternatives, but I was curious to see how hard it would be to hack something useful myself, as a creative solution.

This evening I spotted Protocol::Redis, which is a perl module for decoding/encoding data to/from a Redis server.

Thinking "Ahah" I wired this module up to AnyEvent::Socket. The end result was predis - A perl-implementation of Redis.

It's a limited implementation which stores data in an SQLite database, and currently has support for:

  • get/set
  • incr/decr
  • del/ping/info

It isn't hugely fast, but it is fast enough, and it should be possible to use alternative backends in the future.

I suspect I'll not add sets/hashes, but it could be done if somebody was keen.



Comments on this entry

icon apeiron at 00:51 on 12 July 2014

I don't see how this could possibly be a memory savings unless you're not actually storing anything in the perl process, which is really the antithesis of the point of redis.

icon Steve Kemp at 05:51 on 12 July 2014

The data is being get/set/incr/decrc to an SQLite database. So not all of it needs to fit into RAM.

Which was the whole point.