Documentation
¶
Index ¶
Constants ¶
This section is empty.
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.
func NewCache ¶
func NewCache(ne NewEncoder, nd NewDecoder, clearCache bool, appPath string, opts ...Option) (*Cache, error)
type Decoder ¶ added in v0.3.0
Decoder defines a basic interface for the Decode implementations. The Cache uses the Decoder instance when retrieving the state.
type Encoder ¶ added in v0.3.0
Encoder defines a basic interface for the Encode implementations. The Cache uses the Encoder instance when persisting the state.
type NewDecoder ¶ added in v0.3.0
NewDecoder defines a function type that returns a new Decoder instance. This function will be called on each cache restoring operation since the io.Reader may differ.
type NewEncoder ¶ added in v0.3.0
NewEncoder defines a function type that returns a new Encoder instance. This function will be called on each cache persistent operation since the io.Writer may differ.