feat: optimize exists to check multiple keys in one call (#40)

* closes #32
This commit is contained in:
2024-10-07 10:07:11 +03:00
committed by GitHub
parent fd59d286f5
commit f1086fcdc1
4 changed files with 13 additions and 14 deletions

View File

@@ -26,9 +26,14 @@ func (c *mapCache) Remove(_ context.Context, key string) error {
return nil
}
func (c *mapCache) Exists(_ context.Context, key string) (bool, error) {
_, ok := c.xmap.Load(key)
return ok, nil
func (c *mapCache) Exists(_ context.Context, key ...string) (bool, error) {
for _, v := range key {
_, ok := c.xmap.Load(v)
if ok {
return true, nil
}
}
return false, nil
}
func (c *mapCache) Size(_ context.Context) (int64, error) {