Documentation ¶
Index ¶
- Variables
- type CleanResult
- type Client
- func (c *Client) Clean() ([]CleanResult, error)
- func (c *Client) Delete(key string) error
- func (c *Client) Expire(key string) bool
- func (c *Client) Get(key string, output interface{}) (interface{}, error)
- func (c *Client) GetJson(key string) ([]byte, error)
- func (c *Client) List() ([]Index, error)
- func (c *Client) Outdated() ([]string, error)
- func (c *Client) Set(key string, val interface{}, expire int64) error
- func (c *Client) Update(key string, updater UpdateFunc, expire int64, output interface{}) (interface{}, error)
- func (c *Client) UpdateJson(key string, updater UpdateFunc, expire int64) ([]byte, error)
- type Index
- type IndexList
- type UpdateFunc
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type CleanResult ¶
type CleanResult struct { // The bucket name that saved cache data. Bucket string // Error when delete the specified bucket. Error error }
The structure is used when use clean method.
type Client ¶
type Client struct { // Cache Index list Indexer IndexList }
Cache client
func (*Client) Clean ¶
func (c *Client) Clean() ([]CleanResult, error)
Clean is used to delete no-indexed bucket. Example:
cli, err := honoka.New() result, err := cli.Clean()
func (*Client) Delete ¶
Delete is used to delete a cache by specified key.
Example:
cli, err := honoka.New() err = cli.Delete("foobar")
func (*Client) Expire ¶
Expire is a predicate which determines if the cache should be updated.
Example:
cli, err := honoka.New() expired := cli.Expire("foobar")
func (*Client) Get ¶
Get is used to retrieve a cache by specified key.
Example:
cli, err := honoka.New() var output interface{} cli.Get("foobar", &output) // OR result, err := cli.Get("foobar", &output)
func (*Client) GetJson ¶
Get is used to retrieve a cache by specified key. Return value is JSON string Example:
cli, err := honoka.New() result, err := cli.GetJson("foobar")
func (*Client) List ¶
List is used to retrive cache indexes.
Example:
cli, err := honoka.New() list, err := cli.List()
func (*Client) Outdated ¶
Outdated is used to retrive no-indexed bucket.
Example:
cli, err := honoka.New() list, err := cli.Outdated()
func (*Client) Set ¶
Get is used to create a cache if specified key has not used yet.
Example:
cli, err := honoka.New() err := cli.Set("foobar", "fizzbizz", 100)
func (*Client) Update ¶
func (c *Client) Update(key string, updater UpdateFunc, expire int64, output interface{}) (interface{}, error)
Update calls the cache update function on the cached data. Get is used to retrieve a cache by specified key.
Example:
cli, err := honoka.New() var output interface{} f := func() { return "fizzbizz" } cli.Update("foobar", f, 100, &output) // OR result, err := cli.Get("foobar", f, 100, &output)
func (*Client) UpdateJson ¶
Update calls the cache update function on the cached data. Return value is JSON string.
Example:
cli, err := honoka.New() f := func() { return "fizzbizz" } result, err := cli.UpdateJson("foobar", f, 100)
type Index ¶
type Index struct { // The index key. Key string // The bucket name that saved cache data. Bucket string // The maximum elapsed time since the last file update. Expiration int64 }
Cache index
type UpdateFunc ¶
type UpdateFunc func() (interface{}, error)