Skip to content
yinqiwen edited this page May 11, 2016 · 4 revisions

Internal Codec Format

General key format is <namespace> <key> <type> <element...>, while general value format is <type> <element...>. If the storage backend support namespace, the namespace part would not be encoded in the key.

                     KeyObject                                                   ValueObject
String      [<namespace>]  <key> KEY_META                                   KEY_STRING <MetaObject>
Hash        [<namespace>]  <key> KEY_META                                   KEY_HASH <MetaObject>
            [<namespace>]  <key> KEY_HASH_FIELD <field>                     KEY_HASH_FIELD <field-value>
Set         [<namespace>]  <key> KEY_META                                   KEY_SET <MetaObject>
List        [<namespace>]  <key> KEY_SET_MEMBER <member>                    KEY_SET_MEMBER
Sorted Set  [<namespace>]  <key> KEY_META                                   KEY_ZSET <MetaObject>
            [<namespace>]  <key> KEY_ZSET_SCORE <member>                    KEY_ZSET_SCORE <score>
            [<namespace>]  <key> KEY_ZSET_SORT <score> <member>             KEY_ZSET_SORT

Comparator

For general key format<namespace> <type> <key> <element...>, the comparator would compare namespace first, then ke key, then type, then the key elemetns.

Expire

  • TTL value is always stored in MetaObject for any meta key.
  • Custom Compact Filter Support(rocksdb/forestdb)
    • If storage engine support compact filter, we could check the ttl time while compacting.
  • No Custom Compact Filter
    • New key type KEY_TTL_SORT introduced for the background expire checking task.
    • The KEY_TTL_SORT key format is [<namespace>] "" KEY_TTL_SORT <ttl> <key's namespace> <key>, the key part before KEY_TTL_SORT is empty.
    • A background task scan KEY_TTL_SORT periodlly to delete expired keys.
Clone this wiki locally