https://github.com/juntaki/transparent
Transparent cache and distributed commit to key-value store
https://github.com/juntaki/transparent
cache distributed-transactions golang s3 stack
Last synced: 4 months ago
JSON representation
Transparent cache and distributed commit to key-value store
- Host: GitHub
- URL: https://github.com/juntaki/transparent
- Owner: juntaki
- License: mit
- Created: 2016-11-16T14:14:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-02T15:16:45.000Z (over 9 years ago)
- Last Synced: 2025-03-27T15:21:26.400Z (over 1 year ago)
- Topics: cache, distributed-transactions, golang, s3, stack
- Language: Go
- Homepage:
- Size: 104 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# transparent
Transparent cache and distributed commit to key-value store written in Go.
[](https://travis-ci.org/juntaki/transparent)
[](https://coveralls.io/github/juntaki/transparent?branch=master)
[](https://goreportcard.com/report/github.com/juntaki/transparent)
[](https://godoc.org/github.com/juntaki/transparent)
## Documentation
### Installation
~~~ sh
go get github.com/juntaki/transparent
~~~
### Basic usage
First, create layers and stack them with Stack.Stack().
This example adds LRU memory cache and filesystem cache to dummy source layer.
~~~go
cacheLayer1, _ := lru.NewCache(10, 100)
cacheLayer2 := filesystem.NewCache(10, "/tmp")
sourceLayer := test.NewSource(10)
stack := transparent.NewStack()
stack.Stack(sourceLayer)
stack.Stack(cacheLayer2)
stack.Stack(cacheLayer1)
~~~
If you manipulate the Stack, the value will be transmitted from top layer to the bottom layer transparently.
~~~go
stack.Set("key", []byte("value"))
stack.Sync()
// value, _ = cacheLayer1.Get("key") // "value"
// value, _ = cacheLayer2.Get("key") // "value"
// value, _ = sourceLayer.Get("key") // "value"
value, _ := stack.Get("key")
fmt.Printf("%s\n", value) // "value"
~~~
For details, please refer to [Godoc] (https://godoc.org/github.com/juntaki/transparent).