Пример #1
0
        protected virtual async Task ProcessDeleteByRef(PersistenceRequestHolder <K, Tuple <K, string> > holder)
        {
            var result = await InternalDeleteByRef(holder.Rq.KeyReference, holder);

            if (mCacheManager.IsActive && result.IsSuccess)
            {
                await mCacheManager.Delete(mTransform, mTransform.KeyDeserializer(result.Id));
            }

            ProcessOutputKey(holder.Rq, holder.Rs, result);
        }
Пример #2
0
        /// <summary>
        /// This private method is used to resolve a lookup reference from the cache.
        /// </summary>
        /// <param name="transform">The transform.</param>
        /// <param name="reference">The tuple type/value pair.</param>
        /// <returns>Returns triple with the first boolean property indicating success followed by the key and the version.</returns>
        private async Task <Tuple <bool, K, string> > RedisResolveReference(EntityTransformHolder <K, E> transform, Tuple <string, string> reference)
        {
            if (transform.KeyDeserializer != null)
            {
                try
                {
                    IDatabase rDb     = mLazyConnection.Value.GetDatabase();
                    RedisKey  hashkey = RedisReferenceKeyGet(transform, transform.ReferenceHashMaker(reference));

                    //Entity
                    RedisValue enitityId = await rDb.HashGetAsync(hashkey, cnKeyEntityId);

                    if (enitityId.HasValue)
                    {
                        K key = transform.KeyDeserializer(enitityId);
                        return(new Tuple <bool, K, string>(true, key, await rDb.HashGetAsync(hashkey, cnKeyVersion)));
                    }
                }
                catch (Exception)
                {
                    // Don't raise an exception here
                }
            }

            return(new Tuple <bool, K, string>(false, default(K), null));
        }