Esempio n. 1
0
        public IEntryView <TKey, TValue> GetEntryView(TKey key)
        {
            var keyData       = ToData(key);
            var request       = MapGetEntryViewCodec.EncodeRequest(Name, keyData, GetThreadId());
            var response      = Invoke(request, keyData);
            var parameters    = MapGetEntryViewCodec.DecodeResponse(response);
            var entryView     = new SimpleEntryView <TKey, TValue>();
            var dataEntryView = parameters.Response;

            if (dataEntryView == null)
            {
                return(null);
            }
            entryView.Key                    = ToObject <TKey>(((SimpleEntryView)dataEntryView).Key);
            entryView.Value                  = ToObject <TValue>(((SimpleEntryView)dataEntryView).Value);
            entryView.Cost                   = dataEntryView.Cost;
            entryView.CreationTime           = dataEntryView.CreationTime;
            entryView.ExpirationTime         = dataEntryView.ExpirationTime;
            entryView.Hits                   = dataEntryView.Hits;
            entryView.LastAccessTime         = dataEntryView.LastAccessTime;
            entryView.LastStoredTime         = dataEntryView.LastStoredTime;
            entryView.LastUpdateTime         = dataEntryView.LastUpdateTime;
            entryView.Version                = dataEntryView.Version;
            entryView.EvictionCriteriaNumber = dataEntryView.EvictionCriteriaNumber;
            entryView.Ttl                    = dataEntryView.Ttl;
            //TODO putCache
            return(entryView);
        }
        public IEntryView <K, V> GetEntryView(K key)
        {
            var keyData       = ToData(key);
            var request       = MapGetEntryViewCodec.EncodeRequest(GetName(), keyData, ThreadUtil.GetThreadId());
            var response      = Invoke(request, keyData);
            var parameters    = MapGetEntryViewCodec.DecodeResponse(response);
            var entryView     = new SimpleEntryView <K, V>();
            var dataEntryView = parameters.dataEntryView;

            if (dataEntryView == null)
            {
                return(null);
            }
            entryView.SetKey(ToObject <K>(dataEntryView.GetKey()));
            entryView.SetValue(ToObject <V>(dataEntryView.GetValue()));
            entryView.SetCost(dataEntryView.GetCost());
            entryView.SetCreationTime(dataEntryView.GetCreationTime());
            entryView.SetExpirationTime(dataEntryView.GetExpirationTime());
            entryView.SetHits(dataEntryView.GetHits());
            entryView.SetLastAccessTime(dataEntryView.GetLastAccessTime());
            entryView.SetLastStoredTime(dataEntryView.GetLastStoredTime());
            entryView.SetLastUpdateTime(dataEntryView.GetLastUpdateTime());
            entryView.SetVersion(dataEntryView.GetVersion());
            entryView.SetEvictionCriteriaNumber(dataEntryView.GetEvictionCriteriaNumber());
            entryView.SetTtl(dataEntryView.GetTtl());
            //TODO putCache
            return(entryView);
        }
Esempio n. 3
0
        private async Task <IHDictionaryEntry <TKey, TValue> > GetEntryAsync(TKey key, CancellationToken cancellationToken)
        {
            var keyData = ToSafeData(key);

            var requestMessage  = MapGetEntryViewCodec.EncodeRequest(Name, keyData, ContextId);
            var responseMessage = await Cluster.Messaging.SendToKeyPartitionOwnerAsync(requestMessage, keyData, cancellationToken).CAF();

            var response = MapGetEntryViewCodec.DecodeResponse(responseMessage).Response;

            if (response == null)
            {
                return(null);
            }

            return(new HDictionaryEntry <TKey, TValue>
            {
                Key = ToObject <TKey>(response.Key),
                Value = ToObject <TValue>(response.Value),
                Cost = response.Cost,
                CreationTime = response.CreationTime,
                ExpirationTime = response.ExpirationTime,
                Hits = response.Hits,
                LastAccessTime = response.LastAccessTime,
                LastStoredTime = response.LastStoredTime,
                LastUpdateTime = response.LastUpdateTime,
                Version = response.Version,
                EvictionCriteriaNumber = response.EvictionCriteriaNumber,
                Ttl = response.Ttl
            });
        }