Skip to content

Instantly share code, notes, and snippets.

@dvirsky
Last active May 17, 2016 12:01
Show Gist options
  • Save dvirsky/1ae363ca8f46ed34ac91afd583bb7775 to your computer and use it in GitHub Desktop.
Save dvirsky/1ae363ca8f46ed34ac91afd583bb7775 to your computer and use it in GitHub Desktop.
// A serializer prototype - you serialize by calling Write N times.
// the key type is determined on registration so not needed here
// the list size will be determined by redis when you exit, based on the number of times you called write()
int (*Serialize)(RedisModuleCtx *ctx, RedisModuleObjectWriter *out, RedisModuleKey *k)
// you deserialize by calling Read and reading one object at a time.
// numElements is passed so the user can preallocate stuff in advance
int (*Deserialize)(RedisModuleCtx *ctx, RedisModuleObjectReader *in, RedisModuleString *keyName, size_t numElements)
// reader/writer methods - each one reads or writes a complete object
int ObjectWriter_Write(RedisModuleObjectWriter *w, char *data, size_t len);
int ObjectReader_Read(RedisModuleObjectReader *r, char **data, size_t &len);
// we can add higher level write/read utils, e.g.:
int ObjectWriter_WriteInt64(RedisModuleObjectWriter, int_64_t i);
int ObjectWriter_WriteVarint(RedisModuleObjectWriter, int_64_t i);
.. etc etc - not sure if needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment