Skip to content

Memory Caching in Golang. Preparing for Generics in go1.18.

License

Notifications You must be signed in to change notification settings

lovung/memcache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

memcache

Memory Caching in Golang. Preparing for Generics in go1.18.

It is the very simple memory cache with:

  • Using built-in map of Golang which has been optimized.
  • Using sync.Mutex by shard for thread-safe and avoid cross-shards blocking.
  • Sharding keys with xxh3 algorithm.

Features

  • Set
  • SetUntil
  • Get
  • Take
  • Delete
  • GC

Config

  • Size
  • Shard
  • TTL

Benchmark

Env

goos: darwin
goarch: amd64
pkg: github.com/lovung/memcache
cpu: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz

Results

BenchmarkSet-8           7606341	       132.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkGet-8           11004312	       114.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetTake-8       4407631	       267.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetGetDel-8     4247701	       276.4 ns/op	       0 B/op	       0 allocs/op

About

Memory Caching in Golang. Preparing for Generics in go1.18.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages