func (t *TimedCache) Get(key string, crt AzureCacheReadType) (interface{}, error) {
	entry, err := t.getInternal(key)
	if err != nil {
		return nil, err
	}

	entry.Lock.Lock()
	defer entry.Lock.Unlock()

	// entry exists and if cache is not force refreshed
	if entry.Data != nil && crt != CacheReadTypeForceRefresh {
		// allow unsafe read, so return data even if expired
		if crt == CacheReadTypeUnsafe {
			return entry.Data, nil
		}
		// if cached data is not expired, return cached data
		if crt == CacheReadTypeDefault && time.Since(entry.CreatedOn) < t.TTL {
			return entry.Data, nil
		}
	}
	// Data is not cached yet, cache data is expired or requested force refresh
	// cache it by getter. entry is locked before getting to ensure concurrent
	// gets don't result in multiple ARM calls.
	data, err := t.Getter(key)
	if err != nil {
		return nil, err
	}

	// set the data in cache and also set the last update time
	// to now as the data was recently fetched
	entry.Data = data
	entry.CreatedOn = time.Now().UTC()

	return entry.Data, nil
}
// Get returns the requested item by key.
Get returns the requested item by key.
// Get returns the requested item by key .
func (t *TimedCache) Get(key string, crt AzureCacheReadType) (interface{}, error) {
	entry, err := t.getInternal(key)
	if err != nil {
		return nil, err
	}
	entry.Lock.Lock()
	defer entry.Lock.Unlock()
	if entry.Data != nil && crt != CacheReadTypeForceRefresh {
		if crt == CacheReadTypeUnsafe {
			return entry.Data, nil
		}
		if crt == CacheReadTypeDefault && time.Since(entry.CreatedOn) < t.TTL {
			return entry.Data, nil
		}
	}
	data, err := t.Getter(key)
	if err != nil {
		return nil, err
	}
	entry.Data = data
	entry.CreatedOn = time.Now().UTC()
	return entry.Data, nil
}
func ( t * TimedCache ) Get ( key string , crt AzureCacheReadType ) ( interface { } , error ) { entry , err := t . getInternal ( key ) if err != nil { return nil , err } entry . Lock . Lock ( ) defer entry . Lock . Unlock ( ) if entry . Data != nil && crt != CacheReadTypeForceRefresh { if crt == CacheReadTypeUnsafe { return entry . Data , nil } if crt == CacheReadTypeDefault && time . Since ( entry . CreatedOn ) < t . TTL { return entry . Data , nil } } data , err := t . Getter ( key ) if err != nil { return nil , err } entry . Data = data entry . CreatedOn = time . Now ( ) . UTC ( ) return entry . Data , nil }
Get returns the requested item by key.
Get returns the requested item by key .
// entry exists and if cache is not force refreshed // allow unsafe read, so return data even if expired // if cached data is not expired, return cached data // Data is not cached yet, cache data is expired or requested force refresh // cache it by getter. entry is locked before getting to ensure concurrent // gets don't result in multiple ARM calls. // set the data in cache and also set the last update time // to now as the data was recently fetched