elastic / go-freelru

GC-less, fast and generic LRU hashmap library for Go
Apache License 2.0
145 stars 9 forks source link

for single threaded "mode" do you still need hash? #27

Closed kolinfluence closed 5 months ago

kolinfluence commented 6 months ago

for single threaded "mode" do you still need hash? is it possible to disable hash for single threaded mode?

how do you use single threaded mode by the way?

rockdaboot commented 6 months ago

Maybe there is a misunderstanding. There is no single-threaded "mode". If your cache is only accessed by a single thread/go-routine (concurrency = 1), you should use freelru.New() instead of freelru.NewSynced() or freelru.NewSharded(). The created LRU/cache doesn't use locking.

The underlying data structure is a hashmap, so you need to provide a hash function.

kolinfluence commented 5 months ago

@rockdaboot ok thx.