Alias RedisObjectCollection
Models a strongly typed set of numbered hashes.
alias RedisObjectCollection(T, RedisCollectionOptions OPTIONS = RedisCollectionOptions .defaults, ulong ID_LENGTH = 1)
= RedisCollection!(RedisObject!T,OPTIONS,ID_LENGTH);
This structure is roughly equivalent of a T[long]
.
See also
Example
struct User {
string name;
string email;
int age;
string password;
}
void test()
{
auto db = connectRedis("127.0.0.1") .getDatabase(0);
db .deleteAll();
auto users = RedisObjectCollection!User(db, "users");
assert(users .add(User("Tom", "tom@example.com", 42, "secret")) == 0);
assert(users .add(User("Peter", "peter@example.com", 42, "secret")) == 1);
auto peter = users[1];
assert(peter .name == "Peter");
}