cheapcash/README.md

1.8 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?

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 {

  }

}