Skip to content

Commit

Permalink
Provide a convenience string overload for connectRedisDB
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed Jul 18, 2017
1 parent be6862a commit 57c3a61
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions redis/vibe/db/redis/redis.d
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import std.utf;
*/
RedisClient connectRedis(string host, ushort port = RedisClient.defaultPort)
{
assert(!host.startsWith("redis://"));
return new RedisClient(host, port);
}

Expand All @@ -48,6 +49,17 @@ RedisDatabase connectRedisDB(URL url)
return cli.getDatabase(url.localURI[1 .. $].to!long);
}

/// ditto
RedisDatabase connectRedisDB(string host_or_url)
{
/* If this looks like a URL try to parse it that way. */
if(host_or_url.startsWith("redis://")){
return connectRedisDB(URL(host_or_url));
} else {
return connectRedis(host_or_url).getDatabase(0);
}
}

/**
A redis client with connection pooling.
*/
Expand Down

0 comments on commit 57c3a61

Please sign in to comment.