mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2026-01-04 22:55:48 +08:00
采用更快的Hash算法
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/errors"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/utils"
|
||||
"github.com/dchest/siphash"
|
||||
"github.com/cespare/xxhash"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -170,7 +170,7 @@ func (this *MemoryStorage) AddToList(item *Item) {
|
||||
|
||||
// 计算Key Hash
|
||||
func (this *MemoryStorage) hash(key string) uint64 {
|
||||
return siphash.Hash(0, 0, []byte(key))
|
||||
return xxhash.Sum64String(key)
|
||||
}
|
||||
|
||||
// 清理任务
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package caches
|
||||
|
||||
import (
|
||||
"github.com/dchest/siphash"
|
||||
"github.com/cespare/xxhash"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -80,5 +80,5 @@ func (this *MemoryWriter) ExpiredAt() int64 {
|
||||
|
||||
// 计算Key Hash
|
||||
func (this *MemoryWriter) hash(key string) uint64 {
|
||||
return siphash.Hash(0, 0, []byte(key))
|
||||
return xxhash.Sum64String(key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user