@@ -16,6 +16,10 @@ type RedisCache struct {
1616 port string
1717}
1818
19+ func appendKeyPrefix (key string ) string {
20+ return "expo-open-ota:" + key
21+ }
22+
1923func NewRedisCache (host , password , port string , useTLS bool ) * RedisCache {
2024 opts := & redis.Options {
2125 Addr : host + ":" + port ,
@@ -42,7 +46,7 @@ func (c *RedisCache) Get(key string) string {
4246 ctx , cancel := context .WithTimeout (context .Background (), 2 * time .Second )
4347 defer cancel ()
4448
45- val , err := c .client .Get (ctx , key ).Result ()
49+ val , err := c .client .Get (ctx , appendKeyPrefix ( key ) ).Result ()
4650 if errors .Is (err , redis .Nil ) {
4751 return ""
4852 } else if err != nil {
@@ -60,14 +64,14 @@ func (c *RedisCache) Set(key string, value string, ttl *int) error {
6064 ctx , cancel := context .WithTimeout (context .Background (), 2 * time .Second )
6165 defer cancel ()
6266
63- return c .client .Set (ctx , key , value , expiration ).Err ()
67+ return c .client .Set (ctx , appendKeyPrefix ( key ) , value , expiration ).Err ()
6468}
6569
6670func (c * RedisCache ) Delete (key string ) {
6771 ctx , cancel := context .WithTimeout (context .Background (), 2 * time .Second )
6872 defer cancel ()
6973
70- c .client .Del (ctx , key )
74+ c .client .Del (ctx , appendKeyPrefix ( key ) )
7175}
7276
7377func (c * RedisCache ) Clear () error {
0 commit comments