GetOrSetEntry

Functionin simplecompute-sdk-go v1.11.0View source
func GetOrSetEntry(key []byte, entry CacheEntry) (io.ReadCloser, error)

GetOrSetEntry retrieves the object stored in the cache for the given key if it exists, or inserts and returns the contents provided in the CacheEntry.

The cache entry is only inserted when no value is present for the key, and no other client is in the process of setting it.

If the cache entry body content is costly to compute, consider using GetOrSet instead to avoid creating its io.Reader in the case where the value is already present.

The returned io.ReadCloser must be closed by the caller when finished.

Parameters

key: []byte
entry: CacheEntry

Returns

(io.ReadCloser, error)