Skip to content

Commit

Permalink
修改cacheId为any类型
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Feb 15, 2023
1 parent e3e68b7 commit 47b67e5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cacheInRedis.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ func (r *cacheInRedis) Get() collections.ListAny {
return lst
}

func (r *cacheInRedis) GetItem(cacheId string) any {
func (r *cacheInRedis) GetItem(cacheId any) any {
// 动态创建实体
entityPtr := reflect.New(r.itemType).Interface()

// hash get
exists, err := r.redisClient.HashToEntity(r.key, cacheId, entityPtr)
exists, err := r.redisClient.HashToEntity(r.key, parse.Convert(cacheId, ""), entityPtr)
if err != nil {
_ = flog.Error(err)
}
Expand Down Expand Up @@ -85,8 +85,8 @@ func (r *cacheInRedis) SaveItem(newVal any) {
}
}

func (r *cacheInRedis) Remove(cacheId string) {
_, err := r.redisClient.HashDel(r.key, cacheId)
func (r *cacheInRedis) Remove(cacheId any) {
_, err := r.redisClient.HashDel(r.key, parse.Convert(cacheId, ""))
if err != nil {
_ = flog.Error(err)
}
Expand All @@ -103,8 +103,8 @@ func (r *cacheInRedis) Count() int {
return r.redisClient.HashCount(r.key)
}

func (r *cacheInRedis) ExistsItem(cacheId string) bool {
exists, err := r.redisClient.HashExists(r.key, cacheId)
func (r *cacheInRedis) ExistsItem(cacheId any) bool {
exists, err := r.redisClient.HashExists(r.key, parse.Convert(cacheId, ""))
if err != nil {
_ = flog.Error(err)
}
Expand Down

0 comments on commit 47b67e5

Please sign in to comment.