Utilizing SSD as a cheap caching storage
Go to file
Reinaldy Rafli e6f33ca1d4
test: add more test cases
2021-11-16 12:13:49 +07:00
.github/workflows fix: removing race from ci 2021-11-16 12:01:41 +07:00
.editorconfig feat: initialize 2021-11-16 11:56:33 +07:00
.gitignore feat: initialize 2021-11-16 11:56:33 +07:00
LICENSE feat: initialize 2021-11-16 11:56:33 +07:00
README.md docs: complete readme example 2021-11-16 11:57:27 +07:00
append.go feat: initialize 2021-11-16 11:56:33 +07:00
append_test.go test: add more test cases 2021-11-16 12:13:49 +07:00
cheapcash.go feat: initialize 2021-11-16 11:56:33 +07:00
cheapcash_test.go feat: initialize 2021-11-16 11:56:33 +07:00
check.go feat: initialize 2021-11-16 11:56:33 +07:00
check_test.go fix: removing race from ci 2021-11-16 12:01:41 +07:00
delete.go fix: removing race from ci 2021-11-16 12:01:41 +07:00
delete_test.go fix: removing race from ci 2021-11-16 12:01:41 +07:00
go.mod feat: initialize 2021-11-16 11:56:33 +07:00
reader.go feat: initialize 2021-11-16 11:56:33 +07:00
reader_test.go test: add more test cases 2021-11-16 12:13:49 +07:00
sanitize.go feat: initialize 2021-11-16 11:56:33 +07:00
writer.go feat: initialize 2021-11-16 11:56:33 +07:00
writer_test.go test: add more test cases 2021-11-16 12:13:49 +07:00

README.md

Cheapcash

Go Reference Go Report Card GitHub CodeFactor codecov Codacy Badge Test and coverage

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 {
    log.Fatal(err)
  }

  err = cache.Delete("users:list")
  if err != nil {
    log.Fatal(err)
  }
}