Storage

FineDB uses LMDB as its storage engine. Data are stored after being compressed using Snappy (by the client or the server).

Stored data

Each data associated to a key is stored like this:

--------------------------------------------------------------------------
| description | replication timestamp | expiration timestamp | data
--------------------------------------------------------------------------
  1 byte        8 bytes                 8 bytes                n bytes
  • description byte: Set of bits which defines some characteristics of the stored data.
  • replication timestamp: Timestamp (microseconds from the Epoch) of the data's creation. Used during replication, to determine if a key must be updated.
  • expiration timestamp: Timestamp (seconds from the Epoch) representing the key's date of expiration. If no expiration was defined on the key, the timestamp's value is undefined.

All timestamps are stored as 64 bits unsigned integers, in network byte order (big endian).

Description byte

,----------------> unused bits
| | | | |
1 1 1 1 1 1 1 1
          | | |
          | | `--> serialized data [1]
          | |
          | `----> replicated data [2]
          |
          `------> expiration [3]

[1]: The stored stream is a MessagePack serialization of complex structured data.
[2]: The key was received as replicated data. If set to zero, it means that the key was created on this server.
[3]: An expiration date was defined for this key.