https://github.com/a-hilaly/memcache
A small memcache implementation Go
https://github.com/a-hilaly/memcache
auditing memcache threadsafe
Last synced: 7 months ago
JSON representation
A small memcache implementation Go
- Host: GitHub
- URL: https://github.com/a-hilaly/memcache
- Owner: a-hilaly
- License: apache-2.0
- Created: 2018-04-27T16:33:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-03T10:58:39.000Z (about 7 years ago)
- Last Synced: 2024-12-27T04:07:54.294Z (over 1 year ago)
- Topics: auditing, memcache, threadsafe
- Language: Go
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Audit: audit.go
Awesome Lists containing this project
README
# memcache
[](https://circleci.com/gh/A-Hilaly/memcache/tree/master) [](https://codecov.io/gh/A-Hilaly/memcache)
Zero dependencies memcache key|value store library. It supports multi threaded programs and offer an easy to use auditing properties.
### Features
- Zero dependencies
- Thread safe cache & store objects
- Audit utilities to delete expired items
### Usage
```shell
go get -u github.com/a-hilaly/memcache
```
### Example
```go
package main
import (
"fmt"
"time"
"github.com/a-hilaly/memcache"
)
func main() {
// create new cache
mc := memcache.New(10, 10, 2*time.Second)
// create audit fn
auditFn := memcache.NewAuditorFunc(time.Millisecond*100, time.Millisecond*500)
// start auditing
done, stop := auditFn(mc)
// put some key & value
mc.Put("key1", "value")
time.Sleep(time.Second * 1)
// put key2
mc.Put("key2", "value2")
time.Sleep(time.Second * 1)
// send stop signal to the goroutine auditing the cache
stop <- struct{}{}
// wait for it to finish
<-done
// check keys values
fmt.Println(mc.Get("key")) // expired
fmt.Println(mc.Get("key2")) // still exists
}
}
```
### Benchmarks
see [BENCHMARKS.md](BENCHMARKS.md)