Files
Roman Sharkov 34ca1ca22a Implement invalidation through DELETE /cache/all (#8)
* Implement invalidation through `DELETE /cache/all`

* Fix review issues

* Fix review issues
2019-11-28 20:07:58 +01:00

42 lines
869 B
Go

package content
import (
"github.com/foomo/neosproxy/cache/content/store"
)
// Get a cache item, if it exists
func (c *Cache) Get(id, dimension, workspace string) (item store.CacheItem, err error) {
hash := store.GetHash(id, dimension, workspace)
cachedItem, errGet := c.store.Get(hash)
if errGet != nil {
err = errGet
return
}
item = cachedItem
return
}
// Len will return the number of cached items
func (c *Cache) Len() int {
counter, errCounter := c.store.Count()
if errCounter != nil {
return 0
}
return counter
}
// GetAll returns all cached items
func (c *Cache) GetAll() ([]store.CacheItem, error) {
return c.store.GetAll()
}
func (c *Cache) GetAllEtags(workspace string) (etags map[string]string) {
return c.store.GetAllEtags(workspace)
}
func (c *Cache) GetEtag(hash string) (etag string, e error) {
return c.store.GetEtag(hash)
}