The one with Redis

70 points

Your task is to grab a Redis snapshot from our API and extract some [meta-]data about the contents.

Every time you send a request to the problem endpoint, you'll get back a new, neatly-crafted Redis snapshot with a few fun things inside:

  • a few totally boring keys with equally boring values
  • one emoji key - that's right, there's no running from it
  • one key with an expiry time set

Data will be spread out over a few databases.

To solve the challenge, extract the expiry timestamp of that one key, extract the value of the emoji key (as in, the value the key is set to, not the actual emoji codepoint) and the number of non-empty databases inside the snapshot. Oh, and we'll ask that you also check the type of one of the keys inside and send that back. You'll get the name of the key in the problem JSON.

Minor inconvenience, though - looks like the header may have been... tampered with by a truly demonic, envious entity. Nothing too serious, though.

Getting the problem set

GET /challenges/the_redis_one/problem?access_token=...

Problem JSON structure is simple:

  • rdb: a base64 encoded Redis snapshot
  • requirements:
    • check_type_of: this key right here - we want you to check its type for us

Submitting a solution

POST /challenges/the_redis_one/solve?access_token=...

Your solution should be a JSON with the following keys inside it:

  • db_count: how many databases were initialized
  • emoji_key_value: the value of the emoji key
  • expiry_millis: the timestamp in milliseconds of the only key with an expiry time
  • $check_type_of: the type of the key named $check_type_of (replace with the actual name)

Remember to replace $check_type_of with the actual key name! If the problem JSON contained a "check_type_of": "overweight_geese", solution JSON should contain "overweight_geese": "hash" - or whatever the type will be.


I think on-disk storage formats are awesome. Also, I wanted you to get a taste of the "I bet I could write my own Redis, and it could even understand the official dump format" late-night thought. Originally, I was thinking about generating InnoDB files for you so you see, things could have been way worse to rip apart - but decided to save that for another day. It's coming though, so start warming up and dive into .rdb.

You too can support h^ by buying me a coffee. Cheers!
Also, I'd love to hear from you. Whatever you got, drop me an email. My h^ profile is here.