Documentation ¶
Index ¶
- Variables
- type Cache
- func (c *Cache) CacheFunc(f func() ([]byte, error), name string, cacheTime time.Duration) ([]byte, error)
- func (c *Cache) CacheFuncJSON(f func(interface{}) error, obj interface{}, name string, ...) error
- func (c *Cache) CacheRequest(req *http.Request, cacheTime time.Duration) (*http.Response, error)
- func (c *Cache) CacheRequestData(req *http.Request, cacheTime time.Duration) ([]byte, error)
- func (c *Cache) CacheRequestJSON(req *http.Request, obj interface{}, cacheTime time.Duration) error
- func (c *Cache) CacheURL(u string, cacheTime time.Duration) (*http.Response, error)
- func (c *Cache) CacheURLData(u string, cacheTime time.Duration) ([]byte, error)
- func (c *Cache) CacheURLJSON(u string, obj interface{}, cacheTime time.Duration) error
- type CacheFile
- type CacheStore
- type HTTPClient
Constants ¶
This section is empty.
Variables ¶
View Source
var CacheFileExpired = errors.New("Cache file expired")
View Source
var NotJSONData = errors.New("data is not json formatted")
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func NewCache ¶
func NewCache(store CacheStore, client HTTPClient) *Cache
func (*Cache) CacheFunc ¶
func (c *Cache) CacheFunc(f func() ([]byte, error), name string, cacheTime time.Duration) ([]byte, error)
CacheFunc checks if the file cacheFile exists and is less than cacheTime old. If so, it returns the contents of cacheFile. Otherwise, it executes the function f and, if no error is returned, writes the output to cacheFile and returns the result.
func (*Cache) CacheFuncJSON ¶
func (*Cache) CacheRequest ¶
func (*Cache) CacheRequestData ¶
func (*Cache) CacheRequestJSON ¶
func (*Cache) CacheURLData ¶
type CacheStore ¶
Click to show internal directories.
Click to hide internal directories.