Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dannyben/filecache
Go File Cache
https://github.com/dannyben/filecache
Last synced: 3 months ago
JSON representation
Go File Cache
- Host: GitHub
- URL: https://github.com/dannyben/filecache
- Owner: DannyBen
- License: mit
- Created: 2014-10-09T19:58:55.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-18T17:50:30.000Z (about 10 years ago)
- Last Synced: 2024-10-06T05:20:57.498Z (3 months ago)
- Language: Go
- Size: 156 KB
- Stars: 5
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Go File Cache
=============[![Build Status](https://travis-ci.org/DannyBen/filecache.svg?branch=master)](https://travis-ci.org/DannyBen/filecache) [![GoDoc](https://godoc.org/github.com/DannyBen/filecache?status.png)](http://godoc.org/github.com/DannyBen/filecache)
This package provides easy to use, file system cache functions.
Full documentation is at:
[godoc.org/github.com/DannyBen/filecache](http://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))
}