mirror of
https://github.com/mudler/luet.git
synced 2025-08-30 04:35:10 +00:00
* ⬆️ Bump to go 1.19 as requirement for building Signed-off-by: mudler <mudler@c3os.io> * ⬆️ Update vendor * 🤖 Use go 1.19 in CI * 🤖 Do not pull cover from makefile Signed-off-by: mudler <mudler@c3os.io> * 🤖 Fix permission issues Signed-off-by: mudler <mudler@c3os.io> * 🤖 Adapt test to getcap output changes Signed-off-by: mudler <mudler@c3os.io> --------- Signed-off-by: mudler <mudler@c3os.io> |
||
---|---|---|
.. | ||
.gitignore | ||
cache.go | ||
gofilecache.go | ||
hash.go | ||
LICENSE | ||
README.md |
GOFILECACHE
This is a simple filecache derived from golangs buildcache.
How to use
package main
import (
"crypto/sha512"
"io/ioutil"
"os"
"github.com/rancher-sandbox/gofilecache"
)
func main() {
// Initialise cache
cache := gofilecache.InitCache("temp/")
// pick an example textfile to add to the cache
testFile := "/usr/lib/os-release"
file, _ := os.Open(testFile)
defer file.Close()
// generate a hash under which the entry can be found in the cache
// for simplicity we use the filename here
actionID := sha512.Sum512([]byte("os-release"))
// store the files contents to the cache
cache.Put(actionID, file)
// retrieve the filename from the cache
fileName, _, _ := cache.GetFile(actionID)
// get the files contents
_, _ = ioutil.ReadFile(fileName)
}