You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
372 B
27 lines
372 B
2 years ago
|
package exql
|
||
|
|
||
|
import (
|
||
|
"reflect"
|
||
|
"sync/atomic"
|
||
|
|
||
|
"github.com/upper/db/v4/internal/cache"
|
||
|
)
|
||
|
|
||
|
type hash struct {
|
||
|
v atomic.Value
|
||
|
}
|
||
|
|
||
|
func (h *hash) Hash(i interface{}) string {
|
||
|
v := h.v.Load()
|
||
|
if r, ok := v.(string); ok && r != "" {
|
||
|
return r
|
||
|
}
|
||
|
s := reflect.TypeOf(i).String() + ":" + cache.Hash(i)
|
||
|
h.v.Store(s)
|
||
|
return s
|
||
|
}
|
||
|
|
||
|
func (h *hash) Reset() {
|
||
|
h.v.Store("")
|
||
|
}
|