Documentation
¶
Index ¶
Constants ¶
const DefaultCachePath = "./cache"
DefaultCachePath defines a default path for storing file cache entries.
Variables ¶
var ErrNoCache = errors.New("cache entry not found")
ErrNoCache defines an error that may occur if the requested cache entry was not found.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache provides a file cache API. It saves and restores an arbitrary data types which can marshaled/unmarshalled as JSON into file cache. The cache entries can be restored by the corresponding key. The cache files will be stored at configured path or default DefaultCachePath will be used.
type Option ¶
type Option func(*Cache)
Option defines a type for providing configuration options for Cache instance.
func WithCacheDir ¶
WithCacheDir allows setting a custom path for storing cache files. By default, DefaultCachePath will be used.
func WithCompress ¶
WithCompress enables or disables compression of cache files. By default it's enabled.