[#488] Change cache key types

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-06-28 15:56:41 +03:00 committed by Alex Vanin
parent e104855633
commit 206a7aa395
5 changed files with 24 additions and 27 deletions

View file

@ -34,7 +34,7 @@ type (
// ObjectsListKey is a key to find a ObjectsListCache's entry.
ObjectsListKey struct {
cid string
cid cid.ID
prefix string
latestOnly bool
}
@ -106,7 +106,6 @@ func (l *ObjectsListCache) PutVersions(key ObjectsListKey, versions []*data.Node
// CleanCacheEntriesContainingObject deletes entries containing specified object.
func (l *ObjectsListCache) CleanCacheEntriesContainingObject(objectName string, cnr cid.ID) {
cidStr := cnr.EncodeToString()
keys := l.cache.Keys(true)
for _, key := range keys {
k, ok := key.(ObjectsListKey)
@ -115,7 +114,7 @@ func (l *ObjectsListCache) CleanCacheEntriesContainingObject(objectName string,
zap.String("expected", fmt.Sprintf("%T", k)))
continue
}
if cidStr == k.cid && strings.HasPrefix(objectName, k.prefix) {
if cnr.Equals(k.cid) && strings.HasPrefix(objectName, k.prefix) {
l.cache.Remove(k)
}
}
@ -124,7 +123,7 @@ func (l *ObjectsListCache) CleanCacheEntriesContainingObject(objectName string,
// CreateObjectsListCacheKey returns ObjectsListKey with the given CID, prefix and latestOnly flag.
func CreateObjectsListCacheKey(cnr cid.ID, prefix string, latestOnly bool) ObjectsListKey {
p := ObjectsListKey{
cid: cnr.EncodeToString(),
cid: cnr,
prefix: prefix,
latestOnly: latestOnly,
}