Skip to content

Repository files navigation

Memkey

Go VersionLicenseGoDocGo Report Card

Memkey is a fast, lightweight in-memory key-value store for Go.

Features

  • 🚀 Fast, lightweight in-memory key-value store.
  • ⏰ Optional TTL per key.
  • ✨ Background cleanup to remove expired keys.
  • 🔐 Concurrent-safe.

Installation

go get -u github.com/byterio/memkey

Usage

package main
import (
"fmt""time""github.com/byterio/memkey"
)
funcmain() {
mk:=memkey.New()
defermk.Close()
mk.Set("ping", []byte("pong"), 5*time.Second)
mk.Set("foo", []byte("bar"), 0)
ifmk.Has("ping") {
v, _:=mk.Get("ping")
fmt.Println(string(v)) // prints "pong"
}
time.Sleep(6*time.Second)
ifmk.Has("foo") {
v, _:=mk.Get("foo")
fmt.Println(string(v)) // prints "bar"
}
if!mk.Has("ping") {
fmt.Println("expired")
}
}

Benchmarks

Benchmark on an Intel Core i7-6700HQ CPU @ 2.60GHz:

BenchmarkIterationsns/opB/opallocs/op
Benchmark_Memkey_Set-812,485,83591.7241
Benchmark_Memkey_Get-830,052,06439.7700
Benchmark_Memkey_SetAndDelete-86,038,889194.441

Feedback and Contributions

If you encounter any issues or have suggestions for improvement, please open an issue on GitHub.

We welcome contributions! Fork the repository, make your changes, and submit a pull request.

Support

If you enjoy using Memkey, please consider giving it a star! Your support helps others discover the project and encourages further development.

License

Memkey is open-source software released under the Apache License, Version 2.0. You can find a copy of the license in the LICENSE file.

Releases

Packages

Contributors

Languages