You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
default to 128bit hashing for collision checks (#98)
* 128bit hashing by default
* remove unused, add documentation
* use config func if provided
* test fix
* fix review comments, add todo for memhash128
* fix
Copy file name to clipboardExpand all lines: README.md
+6-12
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,6 @@ Ristretto is usable but still under active development. We expect it to be produ
38
38
* [OnEvict](#Config)
39
39
* [KeyToHash](#Config)
40
40
* [Cost](#Config)
41
-
* [Hashes](#Config)
42
41
*[Benchmarks](#Benchmarks)
43
42
* [Hit Ratios](#Hit-Ratios)
44
43
* [Search](#Search)
@@ -109,14 +108,18 @@ If for some reason you see Get performance decreasing with lots of contention (y
109
108
110
109
Metrics is true when you want real-time logging of a variety of stats. The reason this is a Config flag is because there's a 10% throughput performance overhead.
111
110
112
-
**OnEvict**`func(keyHash uint64, value interface{}, cost int64)`
111
+
**OnEvict**`func(hashes [2]uint64, value interface{}, cost int64)`
113
112
114
113
OnEvict is called for every eviction.
115
114
116
-
**KeyToHash**`func(key interface{}) uint64`
115
+
**KeyToHash**`func(key interface{}) [2]uint64`
117
116
118
117
KeyToHash is the hashing algorithm used for every key. If this is nil, Ristretto has a variety of [defaults depending on the underlying interface type](https://github.com/dgraph-io/ristretto/blob/master/z/z.go#L19-L41).
119
118
119
+
Note that if you want 128bit hashes you should use the full `[2]uint64`,
120
+
otherwise just fill the `uint64` at the `0` position and it will behave like
121
+
any 64bit hash.
122
+
120
123
**Cost**`func(value interface{}) int64`
121
124
122
125
Cost is an optional function you can pass to the Config in order to evaluate
@@ -129,15 +132,6 @@ To signal to Ristretto that you'd like to use this Cost function:
129
132
1. Set the Cost field to a non-nil function.
130
133
2. When calling Set for new items or item updates, use a `cost` of 0.
131
134
132
-
**Hashes**`uint8`
133
-
134
-
Hashes is the number of 64-bit hashes to chain and use as unique identifiers.
135
-
For example, if Hashes is 2, Ristretto will use 128-bit hashes to verify and
136
-
protect against collisions. If Hashes is 3, Ristretto will use 192-bit hashes,
137
-
etc.
138
-
139
-
If this value is 0 or 1, 64-bit hashes will be used.
140
-
141
135
## Benchmarks
142
136
143
137
The benchmarks can be found in https://github.com/dgraph-io/benchmarks/tree/master/cachebench/ristretto.
0 commit comments