Ejemplo n.º 1
0
        protected virtual bool GetCacheInstance(string key, ICacheDataConverter converter, out object value)
        {
            value = null;
            var byteData = Cache.Get(key);

            if (byteData == null)
            {
                return(false);
            }

            DistributeData data = DistributeData.FromDistributeData(byteData);

            if (!data.Dependency.HasChanged)
            {
                value = data.CreateCacheObject(converter);
                return(true);
            }
            else
            {
                Cache.Remove(key);
            }

            value = null;
            return(false);
        }
Ejemplo n.º 2
0
        protected override bool GetCacheInstance(string key, ICacheDataConverter converter, out object value)
        {
            value = null;
            DistributeData data;

            if (fCacheTable.TryGetValue(key, out var localCache))
            {
                if (localCache.TryGetTarget(out data))
                {
                    if (!data.Dependency.HasChanged)
                    {
                        value = data.CreateCacheObject(converter);
                        return(true);
                    }
                    else
                    {
                        Remove(key);
                        return(false);
                    }
                }
            }

            var byteData = Cache.Get(key);

            if (byteData == null)
            {
                return(false);
            }

            data = DistributeData.FromDistributeData(byteData);
            if (!data.Dependency.HasChanged)
            {
                value            = data.CreateCacheObject(converter);
                fCacheTable[key] = new WeakReference <DistributeData>(data);
                return(true);
            }
            else
            {
                Remove(key);
            }

            value = null;
            return(false);
        }