mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
lib/cache: add PutErr to put a value with an error into the cache
This commit is contained in:
10
lib/cache/cache.go
vendored
10
lib/cache/cache.go
vendored
@@ -124,8 +124,8 @@ func (c *Cache) Unpin(key string) {
|
||||
c.addPin(key, -1)
|
||||
}
|
||||
|
||||
// Put puts a value named key into the cache
|
||||
func (c *Cache) Put(key string, value interface{}) {
|
||||
// PutErr puts a value named key with err into the cache
|
||||
func (c *Cache) PutErr(key string, value interface{}, err error) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if c.noCache() {
|
||||
@@ -134,11 +134,17 @@ func (c *Cache) Put(key string, value interface{}) {
|
||||
entry := &cacheEntry{
|
||||
value: value,
|
||||
key: key,
|
||||
err: err,
|
||||
}
|
||||
c.used(entry)
|
||||
c.cache[key] = entry
|
||||
}
|
||||
|
||||
// Put puts a value named key into the cache
|
||||
func (c *Cache) Put(key string, value interface{}) {
|
||||
c.PutErr(key, value, nil)
|
||||
}
|
||||
|
||||
// GetMaybe returns the key and true if found, nil and false if not
|
||||
func (c *Cache) GetMaybe(key string) (value interface{}, found bool) {
|
||||
c.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user