mirror of
https://github.com/grassrootseconomics/eth-tracker.git
synced 2026-05-20 11:21:09 +02:00
feat: optimize exists to check multiple keys in one call (#40)
* closes #32
This commit is contained in:
11
internal/cache/xmap.go
vendored
11
internal/cache/xmap.go
vendored
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user