cheapcash/README.md

70 lines
2.4 KiB
Markdown
Raw Normal View History

2021-11-16 04:56:33 +00:00
# Cheapcash
[![Go Reference](https://pkg.go.dev/badge/github.com/aldy505/cheapcash.svg)](https://pkg.go.dev/github.com/aldy505/cheapcash) [![Go Report Card](https://goreportcard.com/badge/github.com/aldy505/cheapcash)](https://goreportcard.com/report/github.com/aldy505/cheapcash) ![GitHub](https://img.shields.io/github/license/aldy505/cheapcash) [![CodeFactor](https://www.codefactor.io/repository/github/aldy505/cheapcash/badge)](https://www.codefactor.io/repository/github/aldy505/cheapcash) [![codecov](https://codecov.io/gh/aldy505/cheapcash/branch/master/graph/badge.svg?token=Noeexg5xEJ)](https://codecov.io/gh/aldy505/cheapcash) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/9b78970127c74c1a923533e05f65848d)](https://www.codacy.com/gh/aldy505/cheapcash/dashboard?utm_source=github.com&utm_medium=referral&utm_content=aldy505/cheapcash&utm_campaign=Badge_Grade) [![Test and coverage](https://github.com/aldy505/cheapcash/actions/workflows/ci.yml/badge.svg)](https://github.com/aldy505/cheapcash/actions/workflows/ci.yml)
SSD is cheap. Why don't we use it for caching?
2021-11-19 10:55:31 +00:00
A simple library implementing filesystem I/O as a cache. Should be must useful when used again a Solid State Drive
for maximum speed and to handle good amount of concurrent read/write.
The API itself is also pretty simple considering I don't want this to be a full-blown caching library like Redis,
I just want it to be simple like Bigcache or similar caching library.
2021-11-16 04:56:33 +00:00
## Install
```go
import "github.com/aldy505/cheapcash"
```
## Usage
It has simple API for reading & storing cache.
```go
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 {
2021-11-16 04:57:27 +00:00
log.Fatal(err)
2021-11-16 04:56:33 +00:00
}
2021-11-16 04:57:27 +00:00
err = cache.Delete("users:list")
if err != nil {
log.Fatal(err)
}
2021-11-16 04:56:33 +00:00
}
2021-11-16 04:57:27 +00:00
```
2021-11-19 10:55:31 +00:00
See Godoc documentation (link above, beneath the title) for more complete documentation of the package.
## License
[MIT](./LICENSE)