Skip to content
This repository has been archived by the owner on Jun 21, 2019. It is now read-only.

删除缓存卡顿的问题 #7

Open
god1991 opened this issue May 30, 2019 · 3 comments
Open

删除缓存卡顿的问题 #7

god1991 opened this issue May 30, 2019 · 3 comments

Comments

@god1991
Copy link

god1991 commented May 30, 2019

func (c *RedisCacher) delObjects(key string) error {

c.logDebugf("delObjects key:[%s]", key)

conn := c.pool.Get()
defer conn.Close()

keys, err := conn.Do("KEYS", key)
c.logDebugf("delObjects keys: %v", keys)

if err == nil {
	for _, key := range keys.([]interface{}) {
		conn.Do("DEL", key)
	}
}
return err

}

删除的时候用到了keys命令,db里面的key比较多的时候会导致卡顿,可以改成scan嘛?

此外,这个redis缓存好久不更新了,有生成使用的例子嘛?

@lunny
Copy link
Member

lunny commented May 30, 2019

Could you send a PR to fix that?

@god1991
Copy link
Author

god1991 commented May 31, 2019

I try it

@god1991
Copy link
Author

god1991 commented Jun 4, 2019

#8

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants