func (c *Cache) Set(key string, data interface{}, d time.Duration) {
	wd, err := os.Create(path.Join(c.path, key))
	if err != nil {
		log.Fatalln(err)
	}
	defer wd.Close()
	t := time.Now().Add(d)
	b, err := json.Marshal(genericCache{&t, data})
	if err != nil {
		log.Fatalln(err)
	}
	wd.Write(b)
}
Set stores the data in a file identified by the key and with the lifetime of d
package launchbar
import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"path"
	"path/filepath"
	"time"
)
type CacheError string
func (c CacheError) Error() string {
	return string(c)
}
var (
	ErrCacheDoesNotExists = CacheError("the cache does not exists")
	ErrCacheIsCorrupted   = CacheError("the cache is corrupted")
	ErrCacheIsExpired     = CacheError("the cache is expired")
)
type Cache struct {
	path string
}
func NewCache(p string) *Cache {
	return &Cache{path: p}
}
type cacheItem struct {
	Time  *time.Time `json:"expiry"`
	Items []*item    `json:"items"`
}
type genericCache struct {
	Time *time.Time  `json:"expiry"`
	Data interface{} `json:"data"`
}
func (c *Cache) Delete(key string) {
	if !path.IsAbs(c.path) || path.Dir(c.path) != os.ExpandEnv("$HOME/Library/Caches/at.obdev.LaunchBar/Actions") {
		panic(fmt.Sprintf("bad cache path: %q", c.path))
	}
	p := path.Join(c.path, key)
	if stat, err := os.Stat(p); err == nil {
		if !stat.IsDir() {
			if filepath.Dir(p) == c.path {
				os.Remove(p)
			}
		}
	}
}