Hunt Redis 是使用 D 語言開發的 Redis 客戶端,非常容易使用,API 移植自 Java 界最易用的 Redis 客戶端項目 Jedis ,兼容 Redis 2.8.x / 3.x / 4.x / 5.x 。
目前已經經過一段時間的測試正式發布 1.0.0 版本,歡迎體驗,下方有示例代碼。
import hunt.redis;
import std.stdio : writeln;
void main()
{
auto redis = new Redis("localhost");
redis.set("foo", "bar");
string value = redis.get("foo");
writeln(value); // 列印 bar
}
Redis Cluster 使用示例:
import hunt.redis;
import std.stdio;
void main()
{
auto redisClusterNodes = new HashSet!(HostAndPort)();
redisClusterNodes.add(new HostAndPort("127.0.0.1", 7379));
auto rc = new RedisCluster(redisClusterNodes);
rc.set("foo", "bar");
string value = rc.get("foo");
writeln(value); // 列印 bar
}
[admin
]