Documentation
¶
Index ¶
- Variables
- type Backer
- type Client
- func (self *Client) Close()
- func (self *Client) Delete(key string) error
- func (self *Client) Exists(key string) (bool, error)
- func (self *Client) Get(key string, target interface{}) (bool, error)
- func (self *Client) Health() error
- func (self *Client) Set(key string, value interface{}) error
- func (self *Client) SetExpires(key string, value interface{}, expires time.Duration) error
- func (self *Client) UpdateExpiration(key string, expires time.Duration) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidExpirationTime is returned when an invalid expiration time is // provided to SetExpires ErrInvalidExpirationTime = errors.New("expiration time must be greater than 0") )
Functions ¶
This section is empty.
Types ¶
type Backer ¶
type Backer interface {
// Set sets a value in the backing store.
Set(key string, value []byte) error
// SetExpires sets a value in the backing store that will expire after the
// duration.
SetExpires(key string, value []byte, expires time.Duration) error
// UpdateExpiration sets the expiration for the key. This is useful for updating
// the expiration value of a key that was recently accessed.
UpdateExpiration(key string, expires time.Duration) error
// Get gets a value from the backing store.
Get(key string) ([]byte, bool, error)
// Delete deletes a value from the backing store.
Delete(key string) error
// Exists returns whether a value exists in the backing store. Returns
// ErrNotFound if it does not.
Exists(key string) (bool, error)
// Health returns the health status of the backer.
Health() error
// Close closes the Backer, shutting down any background processes and blocking
// until shutdown is complete.
Close()
}
Backer is an interface defining methods through which a backing store will handle caching and retrieval of data.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client allows for a simple caching interface into any available backing store.
func NewClient ¶
NewClient returns a new caching client configured with your fully-initialized remote backing store.
func (*Client) Close ¶
func (self *Client) Close()
Close closes the client, shutting down any background processes and blocking until shutdown is complete.
func (*Client) Exists ¶
Exists checks to see if the object exists in the cache.
Returns false, nil if the key does not exist.
func (*Client) Get ¶
Get retrieves a value from the cache and populates the target with the result.
Returns ErrNotFound if the key was not present in the cache.
func (*Client) Health ¶ added in v0.0.4
Health returns the current health status of the backer.
Possible return values are:
nil - no issues non-nil error - error reported by the backer
func (*Client) SetExpires ¶
SetExpires sets a value in the cache with the associated expiration time. The minimum resolution for this expiration time is milliseconds.