mirror of https://github.com/aldy505/cheapcash.git
1.8 KiB
1.8 KiB
Cheapcash
SSD is cheap. Why don't we use it for caching?
Install
import "github.com/aldy505/cheapcash"
Usage
It has simple API for reading & storing cache.
package main
import (
"log"
"github.com/aldy505/cheapcash"
)
func main() {
// Create a Cheapcash instance.
// Of course you can make multiple instance for multiple
// root directories.
cache := cheapcash.New("/tmp/cheapcash")
// or if you are feeling lazy
cache = cheapcash.Default()
// path defaults to /tmp/cheapcash
err := cache.Write("users:list", usersList)
if err != nil {
log.Fatal(err)
}
val, err := cache.Read("users:list")
if err != nil {
log.Fatal(err)
}
log.Println(string(val))
err = cache.Append("users:list", []byte("\nMarcel"))
if err != nil {
}
}