/// <summary> /// Put the object into the cache by generating a key for the object based on the blob's properties. /// </summary> /// <param name="properties">Properties of the blob corresponding to the object being written.</param> /// <param name="isDeleteOnFailure">If True, in the case where the cache is unable to insert this object, the local resources pointed to by the Stream (which were to be cached) will be deleted.</param> /// <returns>True if the object was written to the <see cref="IFunctionDataCache"/>, false otherwise.</returns> private bool TryPutToFunctionDataCacheCore(BlobProperties properties, bool isDeleteOnFailure) { string eTag = properties.ETag.ToString(); string id = _blob.BlobClient.Uri.AbsoluteUri; FunctionDataCacheKey cacheKey = new FunctionDataCacheKey(id, eTag); return(_functionDataCache.TryPut(cacheKey, _cacheObject, isIncrementActiveReference: false, isDeleteOnFailure)); }
public bool TryPutToCache(SharedMemoryMetadata cacheObject, bool isIncrementActiveReference) { if (IsCacheHit) { return(false); } return(_functionDataCache.TryPut(CacheKey, cacheObject, isIncrementActiveReference, isDeleteOnFailure: false)); }
/// <summary> /// Put this object in the <see cref="IFunctionDataCache"/>. /// </summary> /// <param name="cacheObject">Details about the shared memory region where this object exists.</param> /// <param name="isIncrementActiveReference">If true, increases the reference counter for this object in the /// <see cref="IFunctionDataCache"/>.</param> /// <returns>True if the object was successfully put into the cache, false otherwise.</returns> public bool TryPutToCache(SharedMemoryMetadata cacheObject, bool isIncrementActiveReference) { if (IsCacheHit) { // The object is already cached return(false); } if (!_functionDataCache.TryPut(CacheKey, cacheObject, isIncrementActiveReference: isIncrementActiveReference, isDeleteOnFailure: false)) { return(false); } // If the ref-count was increased in the cache when adding, it needs to be decremented when this object is disposed _decrementRefCountInCacheOnDispose = isIncrementActiveReference; return(true); }