RedisObjectCollection

Models a strongly typed set of numbered hashes.

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

template RedisObjectCollection (
T
RedisCollectionOptions OPTIONS = RedisCollectionOptions.defaults
size_t ID_LENGTH = 1
) {}

Members

Aliases

RedisObjectCollection
alias RedisObjectCollection = RedisCollection!(RedisObject!T, OPTIONS, ID_LENGTH)
Undocumented in source.

Examples

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");
}

See Also

Meta