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 71dd386 commit 20160dd
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 Down Expand Up @@ -89,6 +90,17 @@ RedisDatabase connectRedisDB(URL url)
return cli.getDatabase(databaseIndex);
}

/// 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 20160dd

Please sign in to comment.