Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrKeyNotPresent = errors.New("key is not present")
)
Functions ¶
This section is empty.
Types ¶
type HashCircler ¶
type HashCircler interface { // Add adds the target key in hash circle. Add(key string) // Hash hashes the input and output the target key which hashes. Hash(input string) (key string, err error) // Delete deletes the target key Delete(key string) }
HashCircler hashes input string to target key, and the key could be enabled or disabled. And the keys array is preset, only the keys could be enable or disable.
func NewConsistentHashCircler ¶
func NewConsistentHashCircler(keys []string, hashFunc func(string) uint64) (HashCircler, error)
NewConsistentHashCircler constructs an instance of HashCircler from keys. And this is thread safety. if hashFunc is nil, it will be set to default hash func.
Click to show internal directories.
Click to hide internal directories.