mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-31 02:26:36 +08:00
优化本地数据库性能
This commit is contained in:
19
internal/utils/fnv/hash.go
Normal file
19
internal/utils/fnv/hash.go
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package fnv
|
||||
|
||||
const (
|
||||
offset64 uint64 = 14695981039346656037
|
||||
prime64 uint64 = 1099511628211
|
||||
)
|
||||
|
||||
// Hash
|
||||
// 非unique Hash
|
||||
func Hash(key string) uint64 {
|
||||
var hash = offset64
|
||||
for _, b := range key {
|
||||
hash ^= uint64(b)
|
||||
hash *= prime64
|
||||
}
|
||||
return hash
|
||||
}
|
||||
Reference in New Issue
Block a user