Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adelowo/onecache
One caching API, Multiple backends
https://github.com/adelowo/onecache
cache golang
Last synced: 28 days ago
JSON representation
One caching API, Multiple backends
- Host: GitHub
- URL: https://github.com/adelowo/onecache
- Owner: adelowo
- License: mit
- Created: 2017-04-14T21:49:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-25T15:44:21.000Z (over 4 years ago)
- Last Synced: 2024-11-07T17:59:14.804Z (about 1 month ago)
- Topics: cache, golang
- Language: Go
- Size: 109 KB
- Stars: 136
- Watchers: 9
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- Changelog: CHANGELOG.MD
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - adelowo/onecache - One caching API, Multiple backends (Go)
- awesome-go - onecache - One caching API, Multiple backends - ★ 79 (Utilities)
- awesome-go-extra - onecache - 04-14T21:49:15Z|2020-05-25T15:44:21Z| (Utilities / Fail injection)
README
### OneCache - A Go caching Library
[![Coverage Status](https://coveralls.io/repos/github/adelowo/onecache/badge.svg)](https://coveralls.io/github/adelowo/onecache)
[![Build Status](https://img.shields.io/travis/adelowo/onecache/master.svg?style=flat-square)](https://travis-ci.org/adelowo/onecache.svg?branch=master)- [Installation](#install)
- [Supported stores](#stores)
- [Examples](#eg)### Installation
```go
$ go get -u github.com/adelowo/onecache
```
Supported cache stores
- [x] InMemory
- [x] Filesystem
- [x] Memcached
- [x] RedisOneCache also comes with ___garbage collection___. This is used by the filesystem and memory adapter to purge out expired items automatically. Please refer to the [examples][eg]
[Examples containing all adapters can be found here][eg]
```go
var store onecache.Storestore = filesystem.MustNewFSStore("/home/adez/onecache_tmp")
err := store.Set("profile", []byte("Lanre"), time.Second*60)
if err != nil {
fmt.Println(err)
return
}value,err := store.Get("profile")
if err != nil {
fmt.Println(err)
return
}fmt.Println(string(value))
```Some adapters like the `filesystem` and `memory` have a ___Garbage collection___ implementation. All
that is needed to call is `store.GC()`. Ideally, this should be called in a `ticker.C`.### LICENSE
MIT[eg]: https://github.com/adelowo/onecache/blob/master/_examples/main.go