William Petit c4a9baf82b
Some checks failed
arcad/edge/pipeline/head There was a failure building this commit
feat: implement lfu based cache strategy
2024-01-08 21:09:45 +01:00

20 lines
400 B
Go

package fs
import (
"strconv"
"github.com/mitchellh/hashstructure/v2"
"github.com/pkg/errors"
)
func DefaultGetKeyHash[K comparable](key K) ([]string, error) {
uintHash, err := hashstructure.Hash(key, hashstructure.FormatV2, nil)
if err != nil {
return nil, errors.WithStack(err)
}
hash := strconv.FormatUint(uintHash, 16)
return []string{hash[0:2], hash[2:4], hash[2:4], hash}, nil
}