aboutsummaryrefslogtreecommitdiffstats
path: root/utils.go
blob: c4ac9e50086d03ba78c29410893eb75318a46bbe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package cache

import (
	"hash/fnv"
)

// zero returns the zero value for the specified type.
func zero[T any]() T {
	var ret T
	return ret
}

// hash computes the 64-bit FNV-1a hash of the provided data.
func hash(data []byte) uint64 {
	hasher := fnv.New64()
	if _, err := hasher.Write(data); err != nil {
		panic(err)
	}
	return hasher.Sum64()
}