vibe.d beta banner
get vibe.d
0.10.0

Asynchronous I/O that doesn’t get in your way, written in D

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

RedisHashCollection

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

Sönke Ludwig

Copyright

© 2014 Sönke Ludwig

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.