Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/OrlovEvgeny/go-mcache
Fast in-memory key:value store/cache with TTL
https://github.com/OrlovEvgeny/go-mcache
bigcache cache fast-cache go-cache golang key-value memcached storage
Last synced: about 2 months ago
JSON representation
Fast in-memory key:value store/cache with TTL
- Host: GitHub
- URL: https://github.com/OrlovEvgeny/go-mcache
- Owner: OrlovEvgeny
- License: mit
- Created: 2018-04-14T23:31:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-21T12:43:35.000Z (almost 5 years ago)
- Last Synced: 2024-10-20T07:49:40.162Z (2 months ago)
- Topics: bigcache, cache, fast-cache, go-cache, golang, key-value, memcached, storage
- Language: Go
- Homepage: https://pkg.go.dev/github.com/OrlovEvgeny/go-mcache?tab=doc
- Size: 49.8 KB
- Stars: 97
- Watchers: 6
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - go-mcache - Fast in-memory key:value store/cache library. Pointer caches. (Database / Caches)
- awesome-go - go-mcache - Fast in-memory key:value store/cache library for Golang - ★ 15 (Data Structures)
- awesome-go-extra - go-mcache - memory key:value store/cache with TTL|83|13|1|2018-04-14T23:31:21Z|2020-01-21T12:43:35Z| (Generators / Caches)
README
# MCache library
[![Build Status](https://travis-ci.org/OrlovEvgeny/go-mcache.svg?branch=master)](https://travis-ci.org/OrlovEvgeny/go-mcache)
[![Go Report Card](https://goreportcard.com/badge/github.com/OrlovEvgeny/go-mcache?v1)](https://goreportcard.com/report/github.com/OrlovEvgeny/go-mcache)
[![GoDoc](https://godoc.org/github.com/OrlovEvgeny/go-mcache?status.svg)](https://godoc.org/github.com/OrlovEvgeny/go-mcache)go-mcache - this is a fast key:value storage.
Its major advantage is that, being essentially a thread-safe .```go
map[string]interface{}
```
with expiration times, it doesn't need to serialize, and quick removal of expired keys.# Installation
```bash
~ $ go get -u github.com/OrlovEvgeny/go-mcache
```**Example a Pointer value (vary fast method)**
```go
type User struct {
Name string
Age uint
Bio string
}func main() {
//Start mcache instance
MCache = mcache.New()//Create custom key
key := "custom_key1"
//Create example struct
user := &User{
Name: "John",
Age: 20,
Bio: "gopher 80 lvl",
}//args - key, &value, ttl (or you need never delete, set ttl is mcache.TTL_FOREVER)
err := MCache.Set(key, user, time.Minute*20)
if err != nil {
log.Fatal(err)
}if data, ok := MCache.Get(key); ok {
objUser:= data.(*User)
fmt.Printf("User name: %s, Age: %d, Bio: %s\n", objUser.Name, objUser.Age, objUser.Bio)
}
}
```### Performance Benchmarks
goos: darwin
goarch: amd64
BenchmarkWrite-4 200000 7991 ns/op
BenchmarkRead-4 1000000 1716 ns/op
BenchmarkRW-4 300000 9894 ns/op
### What should be done- [x] the possibility of closing
- [x] r/w benchmark statistics
- [ ] rejection of channels in safeMap in favor of sync.Mutex (there is an opinion that it will be faster)# License:
[MIT](LICENSE)