Skip to content
Go File Cache
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
README.md
filecache.go
filecache_test.go

README.md

Go File Cache

Build Status GoDoc

This package provides easy to use, file system cache functions.

Full documentation is at: godoc.org/github.com/DannyBen/filecache

Install

$ go get github.com/DannyBen/filecache

Usage

Get the cache handler and set a cache directory and the requested cache life, in minutes:

handler := filecache.Handler{"./cache", 60}

Store data in the cache by providing a string key to the Set method and []byte data. The key's md5 checksum will be used as the filename.

data := []byte("Joey doesn't share food")
handler.Set("testkey", data)

Retrieve data from the cache:

r := handler.Get("testkey")
if r == nil {
	fmt.Println("Cache has expired")
} else  {
	fmt.Println(string(r))
}
You can’t perform that action at this time.