From d9b26088c124f140b8ab3f1aaefd07435cffe5b4 Mon Sep 17 00:00:00 2001 From: id Date: Tue, 19 May 2020 11:13:33 +0300 Subject: [PATCH] feat(redis): add redis client interface, for testing --- cache.go | 2 +- redis_interface.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 redis_interface.go diff --git a/cache.go b/cache.go index f2c045f..c7816bc 100644 --- a/cache.go +++ b/cache.go @@ -16,7 +16,7 @@ type SyncCacheOpts struct { } type SyncCacheClient struct { - redis *redis.Client + redis Redis cacheGroupManager *CacheGroupsManager } diff --git a/redis_interface.go b/redis_interface.go new file mode 100644 index 0000000..ba5a684 --- /dev/null +++ b/redis_interface.go @@ -0,0 +1,13 @@ +package sync_cache + +import ( + "github.com/go-redis/redis" + "time" +) + +type Redis interface { + Get(key string) *redis.StringCmd + Set(key string, value interface{}, expiration time.Duration) *redis.StatusCmd + Del(keys ...string) *redis.IntCmd + FlushDB() *redis.StatusCmd +}