...
This commit is contained in:
@@ -4,7 +4,7 @@ module redisclient
|
||||
pub struct RedisURL {
|
||||
address string = '127.0.0.1'
|
||||
port int = 6379
|
||||
// db int
|
||||
db int
|
||||
}
|
||||
|
||||
pub fn get_redis_url(url string) !RedisURL {
|
||||
@@ -20,5 +20,24 @@ pub fn get_redis_url(url string) !RedisURL {
|
||||
|
||||
pub fn core_get(url RedisURL) !&Redis {
|
||||
mut r := new('${url.address}:${url.port}')!
|
||||
if url.db>0{
|
||||
r.selectdb(url.db)!
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
|
||||
//give a test db, if db is 0, we will set it on 31
|
||||
pub fn test_get(url_ RedisURL) !&Redis {
|
||||
mut url:=url_
|
||||
if url.db==0{
|
||||
url.db=31
|
||||
}
|
||||
return core_get(url)!
|
||||
}
|
||||
|
||||
//delete the test db
|
||||
pub fn test_delete(url_ RedisURL) !&Redis {
|
||||
mut r:= test_get(url)!
|
||||
r.flush()!
|
||||
}
|
||||
Reference in New Issue
Block a user