Example #1
0
func (c *Cache) Get(key string) (resp []byte, ok bool) {
	// Check disk first
	resp, ok = c.disk.Get(key)
	if ok == true {
		log.Debugf("Found %v in disk cache", key)
		return resp, ok
	}
	resp, ok = c.s3.Get(key)
	if ok == true {
		log.Debugf("Found %v in s3 cache: %v", key, s3cache.CacheKeyToObjectKey(key))
		go c.disk.Set(key, resp)
		return resp, ok
	}
	log.Debugf("%v not found in cache: %v", key, s3cache.CacheKeyToObjectKey(key))
	return []byte{}, ok
}
Example #2
0
func (c *Cache) Delete(key string) {
	log.Debugf("Deleting key %v on disk and s3: %v", key, s3cache.CacheKeyToObjectKey(key))
	go c.disk.Delete(key)
	go c.s3.Delete(key)
}
Example #3
0
func (c *Cache) Set(key string, resp []byte) {
	log.Debugf("Setting key %v on disk and s3: %v", key, s3cache.CacheKeyToObjectKey(key))
	go c.disk.Set(key, resp)
	go c.s3.Set(key, resp)
}