Utilizing SSD as a cheap caching storage
Go to file
Reinaldy Rafli 5ee43946ea
Merge pull request #4 from aldy505/docs
docs: added documentations
2021-11-19 22:31: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: added documentations 2021-11-19 17:55:31 +07:00
append.go docs: added documentations 2021-11-19 17:55:31 +07:00
append_test.go feat: rename method 2021-11-16 20:18:23 +07:00
cheapcash.go docs: added documentations 2021-11-19 17:55:31 +07:00
cheapcash_test.go test: panic on new 2021-11-19 18:00:40 +07:00
check.go docs: added documentations 2021-11-19 17:55:31 +07:00
check_test.go feat: rename method 2021-11-16 20:18:23 +07:00
delete.go docs: added documentations 2021-11-19 17:55:31 +07:00
delete_test.go feat: rename method 2021-11-16 20:18:23 +07:00
go.mod feat: initialize 2021-11-16 11:56:33 +07:00
reader.go docs: added documentations 2021-11-19 17:55:31 +07:00
reader_test.go feat: rename method 2021-11-16 20:18:23 +07:00
rename.go docs: added documentations 2021-11-19 17:55:31 +07:00
rename_test.go feat: rename method 2021-11-16 20:18:23 +07:00
sanitize.go docs: added documentations 2021-11-19 17:55:31 +07:00
writer.go docs: added documentations 2021-11-19 17:55:31 +07:00
writer_test.go feat: rename method 2021-11-16 20:18:23 +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?

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