{"modulePath":"github.com/crooks/api_cache","version":"v0.0.0-20251110110223-2afcc6f89f1c","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api_cache\n\ncacher provides disk caching of json retrieved from APIs\n\n## Functions\n\n```go\nfunc MakeCacheFileName(urlStr string) (string, error)\n```\nMakeCacheFilename takes a URL and converts it into a string suitable for making meaningful cache filenames.\n\n## Types\n\n```go\ntype Cache struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewCacher(cacheDir string) *Cache\n```\nNewCacher creates and returns a new instance of Cache.  It takes a directory name where cache files will be stored and will attempt to create that directory if it doesn't exist.\n\n```go\nfunc (c *Cache) AddURL(itemKey, fileName string, validity int64)\n```\nAddURL registers a URL with a filename to contain its cached data.  If the URL has no expiry associated with it, a new entry is created in the expiry cache and immediately set to expired.\n\n```go\nfunc (c *Cache) GetFilename(itemKey string) (string, error)\n```\nGetFilename returns the filename for a given cache item\n\n```go\nfunc (c *Cache) GetURL(itemKey string) (gj gjson.Result, err error)\n```\nGetURL returns the file content associated with a cache key.  If the cache has expired, the content will instead be grabbed from the API.\n\n```go\nfunc (c *Cache) HasExpired(itemKey string) (refresh bool, err error)\n```\nHasExpired takes a cache item and determines if it needs refreshing\n\n```go\nfunc (c *Cache) InitAPI(username, password, cert string)\n```\nInitAPI constructs a new instance of the Satellite API\n\n```go\nfunc (c *Cache) ResetExpire(itemKey string) (err error)\n```\nResetExpire resets the expiry field of a cache Item to current time + the defined validity period\n\n```go\nfunc (c *Cache) SetRefresh()\n```\nSetRefresh instructs GetURL to ignore cached files and fetch (and cache) new copies.\n\n```go\nfunc (c *Cache) WriteExpiryFile() error\n```\nWriteExpiryFile writes the cache expiry map to a file in JSON format.\n\n```go\ntype Item struct {\n\t// contains filtered or unexported fields\n}\n```\nItem contains variables relating to each item stored in the cache\n\n","path":"github.com/crooks/api_cache","name":"api_cache","synopsis":"cacher provides disk caching of json retrieved from APIs","isRedistributable":true}
