cheapcash/README.md

2.4 KiB

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?

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.

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)
  }
}

See Godoc documentation (link above, beneath the title) for more complete documentation of the package.

License

MIT