Steve Kemp's Blog Writings relating to Debian & Free Software

A partial perl-implementation of Redis

Fri, 11 Jul 2014 12:32:38 GMT

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.

| 2 comments.

 

Comments On This Entry

[gravitar] apeiron

Submitted at 00:51:09 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.

[gravitar] Steve Kemp

Submitted at 05:51:52 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.

 

Comments are closed on posts which are more than ten days old.

Spiral Logo

Recent Posts

Recent Tags

Links

Search

Search prior entries:

RSS Feed

  • Subscribe to feed