vibe.db.redis.idioms

Type safe implementations of common Redis storage idioms.

Note that the API is still subject to change!

Types 8

structRedisCollection(T /*: RedisValue*/, RedisCollectionOptions OPTIONS = RedisCollectionOptions.defaults, size_t ID_LENGTH = 1)
Fields
string[ID_LENGTH] m_prefix
string m_suffix
Methods
void initialize(RedisDatabase db, Replicate!(string, ID_LENGTH) name, string suffix = null)
inout(RedisDatabase) database() @property inout
T opIndex(IDS id)
void remove(IDS id)Removes an ID along with the corresponding value.
private string getKey(IDS ids)
Constructors
this(RedisDatabase db, Replicate!(string, ID_LENGTH) name, string suffix = null)
none = 0
supportIteration = 1 << 0
supportPaging = 1 << 1
defaults = supportIteration
structRedisObject(T)

Models a single strongly typed object.

This structure is rougly equivalent to a value of type T. The underlying data is represented as a Redis hash. This means that only primitive fields are supported for T.

Fields
RedisHash!string m_hash
private fieldNames!T keys
Methods
T get() @property
bool exists() @property
void remove()
void opAssign(T val)
private string fields()
private string[T.tupleof.length * 2] toKeysAndValues(T val)
Constructors
this(RedisDatabase db, string key)
this(RedisHash!string hash)
Fields
RedisHash!string m_hash
string m_field
Methods
T get() @property
void opAssign(T val)
void opUnary(string op)() if(op == "++")
void opUnary(string op)() if(op == "--")
void opOpAssign(string op)(long val) if (op == "+")
void opOpAssign(string op)(long val) if (op == "-")
void opOpAssign(string op)(double val) if (op == "+")
void opOpAssign(string op)(double val) if (op == "-")
Constructors
this(RedisHash!string hash, string field)
structRedisLock
Fields
string m_key
string m_scriptSHA
Methods
void performLocked(scope void delegate() del)
Constructors
this(RedisDatabase db, string lock_key)
structJsonEncoded(T)
Fields
T value
Methods
string toString()
structLazyString(T...)
Fields
T m_values
Methods
void toString(void delegate(string) sink)
Constructors
this(T values)
structRedisStripped(T, bool strip_id = true)

Represents the stripped type of a struct.

Strips all fields that cannot be directly stored as values in the Redis database. By default, any field named id or _id is also stripped. Set the strip_id parameter to false to keep those fields.

See_also: redisStrip

Methods
T unstrip(StrippedMembers stripped_members)Reconstructs the full (unstripped) struct value.
private void populateRedisFields(ref T dst, UnstrippedMembers values)
private void populateNonRedisFields(ref T dst, StrippedMembers values)
private string membersString()
Constructors
this(in T src)

Functions 3

fnJsonEncoded!T jsonEncoded(T)(T value)
fnRedisStripped!(T, strip_id) redisStrip(bool strip_id = true, T)(in T val)Strips all non-Redis fields from a struct.
private fnauto toTuple(size_t N, T)(T[N] values)

Templates 13

tmplRedisHashCollection(RedisCollectionOptions OPTIONS = RedisCollectionOptions.defaults, size_t ID_LENGTH = 1)

Models a set of numbered hashes.

This structure is roughly equivalent to a string[string][long] and is commonly used to store collections of objects, such as all users of a service. For a strongly typed variant of this class, see

RedisObjectCollection.

See_also: RedisObjectCollection

tmplRedisObjectCollection(T, RedisCollectionOptions OPTIONS = RedisCollectionOptions.defaults, size_t ID_LENGTH = 1)

Models a strongly typed set of numbered hashes.

This structure is roughly equivalent of a T[long].

See_also: RedisHashCollection

tmplRedisSetCollection(T, RedisCollectionOptions OPTIONS = RedisCollectionOptions.defaults, size_t ID_LENGTH = 1)

Models a strongly typed numbered set of values.

tmplRedisListCollection(T, RedisCollectionOptions OPTIONS = RedisCollectionOptions.defaults, size_t ID_LENGTH = 1)

Models a strongly typed numbered set of values.

tmplRedisStringCollection(T = string, RedisCollectionOptions OPTIONS = RedisCollectionOptions.defaults, size_t ID_LENGTH = 1)

Models a strongly typed numbered set of values.

tmplindicesOf(alias PRED, T...)
tmplFilterToType(alias PRED, T...)
tmplisRedisType(alias F)
tmplisNonRedisType(alias F)
tmplisRedisTypeAndNotID(alias F)
tmplisNonRedisTypeOrID(alias F)
tmplfieldNames(T)
tmplReplicate(T, size_t L)