baz
baz

Reputation: 151

Best way to serialize a byte array key to Redis with Booksleeve

I need to find the best implementation to send a byte array to the key space of a Redis Server with Booksleeve.

I tried different implementation like UTF8 Encoding but i don't know what is the most optimized one in memory of redis server (i will worked with millions of key like this so i really need the shortest in memory key).

Is anyone has already had this requirement?

Upvotes: 2

Views: 4007

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1062770

In the current build for simplicity I've stuck to string keys, however the code would handle binary fine - it uses the binary API. IIRC I received a patch in my inbox just this week that adds binary key support.

Since it seems to be in demand I'll look at that this week.


Edit: a week came and went; the reason being that I'm also doing some work on redis-cluster support, which is going to need some new interfaces anyway, because:

  • not all operations are supported
  • parallel (numbered) databases aren't supported

So basically my plan is to roll both pieces of work into the same branch, giving:

  • a new set of interfaces
    • which use a struct for the key parameter with an implicit conversion operator from string and byte, allowing either to be used interchangeably
    • with the redis-cluster and redis-server commands on separate APIs
    • and a new method on the old connection to get one of the new APIs on a per-DB basis, i.e. Database(3).Keys.Remove(key); or something like that

ETA is still imaginary, but I wanted to explain why I hadn't simply thrown in the existing patch - I think the advent of redis-cluster makes it a good time to revisit the entire API, (but obviously in a way that doesn't break existing code).

Upvotes: 1

Related Questions