/// <summary> /// Recupera uma entrada do cache. /// </summary> /// <param name="key"></param> /// <param name="item"></param> /// <param name="flag"></param> /// <param name="group"></param> /// <param name="subGroup"></param> /// <param name="cacheEntry"></param> /// <returns></returns> public UserBinaryObject GetCacheEntry(string key, ProviderCacheItem item, ref BitSet flag, string group, string subGroup, out CacheEntry cacheEntry) { UserBinaryObject val = null; cacheEntry = null; object serializableObject = null; if ((item != null) && (item.Value != null)) { if ((item.Group == null) && (item.SubGroup != null)) { throw new OperationFailedException("Error occurred while synchronization with data source; group must be specified for sub group"); } if ((group != null) && !CacheHelper.CheckDataGroupsCompatibility(new GroupInfo(item.Group, item.SubGroup), new GroupInfo(group, subGroup))) { throw new OperationFailedException("Error occurred while synchronization with data source; groups are incompatible"); } if (flag == null) { flag = new BitSet(); } serializableObject = item.Value; Hashtable hashtable = new Hashtable(); TypeInfoMap typeInfoMap = _context.CacheRoot.GetTypeInfoMap(); hashtable["query-info"] = CacheLoaderUtil.GetQueryInfo(item.Value, typeInfoMap); if (item.Tags != null) { Hashtable tagInfo = CacheLoaderUtil.GetTagInfo(item.Value, item.Tags); if (tagInfo != null) { hashtable.Add("tag-info", tagInfo); } } if (item.NamedTags != null) { try { Hashtable hashtable3 = CacheLoaderUtil.GetNamedTagsInfo(item.Value, item.NamedTags, typeInfoMap); if (hashtable3 != null) { hashtable.Add("named-tag-info", hashtable3); } } catch (Exception exception) { throw new OperationFailedException("Error occurred while synchronization with data source; " + exception.Message); } } if (!item.Value.GetType().IsSerializable&& !_type.IsAssignableFrom(item.Value.GetType())) { throw new OperationFailedException("Read through provider returned an object that is not serializable."); } serializableObject = SerializationUtil.SafeSerialize(serializableObject, _context.SerializationContext, ref flag); if (_context.CompressionEnabled) { item.Value = CompressionUtil.Compress(item.Value as byte[], ref flag, _context.CompressionThreshold); } val = UserBinaryObject.CreateUserBinaryObject(serializableObject as byte[]); EvictionHint evictionHint = new PriorityEvictionHint(item.ItemPriority); ExpirationHint expiryHint = DependencyHelper.GetExpirationHint(item.Dependency, item.AbsoluteExpiration, item.SlidingExpiration); if (expiryHint != null) { expiryHint.CacheKey = key; if (item.ResyncItemOnExpiration) { expiryHint.SetBit(2); } } cacheEntry = new CacheEntry(val, expiryHint, evictionHint); cacheEntry.Flag = flag; cacheEntry.GroupInfo = new GroupInfo(item.Group, item.SubGroup); cacheEntry.QueryInfo = hashtable; cacheEntry.ResyncProviderName = (item.ResyncProviderName == null) ? null : item.ResyncProviderName.ToLower(); } return(val); }