– An (incomplete) implementation in Perl with persistence

From the memcached FAQ:

How can you list all keys?

With memcached, you can’t list all keys. There is a debug interface, but that is not an advisable usage.

I was working on some stuff with MIMEDefang, Cache::Memcached and memcached at $work and stumbled upon just that. I wanted to check what exactly was going on while developing. About two hours after reading the informal text protocol specification for memcached, I had a crude working implementation of set and get in Perl and keys stored in a BerkeleyDB hash so that they could be inspected by external tools like makemap and postmap.

I’ve cut a lot of corners in this implementation, like:

  • the delete queues are not implemented (yet)
  • no check is done whether the inserted value is of the declared length in bytes
  • an inserted value cannot contain a \n
  • It is not demonizing yet

Give it few nights and enough interest and I think that I may fix those too. So anyway here is the project page and code:

I hope it is useful to at least one more person.

While writing these lines I came up with: Sysadmins do it in Perl, Devops in Python. I do not know how true people may consider this, but indeed Python would have been a much better choice. Oh well, next time.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s