This commit is contained in:
2025-09-15 10:20:09 +02:00
parent ab1044079e
commit 9a41f9e732
22 changed files with 248 additions and 9350 deletions

View File

@@ -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()!
}