public void HandleResponse(GetResponse response)
        {
            if (response.ForceRetry)
            {
                Result        = null;
                RequiresRetry = true;
                return;
            }

            if (response.Result != null)
            {
                if (_clusterSession._session.NoTracking)
                {
                    var result = new Dictionary <string, CompareExchangeValue <T> >(StringComparer.OrdinalIgnoreCase);
                    foreach (var kvp in CompareExchangeValueResultParser <BlittableJsonReaderObject> .GetValues((BlittableJsonReaderObject)response.Result, materializeMetadata: false, _conventions))
                    {
                        if (kvp.Value == null)
                        {
                            result[kvp.Key] = _clusterSession.RegisterMissingCompareExchangeValue(kvp.Key).GetValue <T>(_conventions);
                            continue;
                        }

                        result[kvp.Key] = _clusterSession.RegisterCompareExchangeValue(kvp.Value).GetValue <T>(_conventions);
                    }

                    Result = result;
                    return;
                }

                foreach (var kvp in CompareExchangeValueResultParser <BlittableJsonReaderObject> .GetValues((BlittableJsonReaderObject)response.Result, materializeMetadata: false, _conventions))
                {
                    if (kvp.Value == null)
                    {
                        continue;
                    }

                    _clusterSession.RegisterCompareExchangeValue(kvp.Value);
                }
            }

            if (_keys != null)
            {
                foreach (var key in _keys)
                {
                    if (_clusterSession.IsTracked(key))
                    {
                        continue;
                    }

                    _clusterSession.RegisterMissingCompareExchangeValue(key);
                }
            }

            Result = _clusterSession.GetCompareExchangeValuesFromSessionInternal <T>(_keys, out var notTrackedKeys);
            Debug.Assert(_clusterSession._session.NoTracking || notTrackedKeys == null, "notTrackedKeys == null");
        }
예제 #2
0
        public void HandleResponse(GetResponse response)
        {
            if (response.ForceRetry)
            {
                Result        = null;
                RequiresRetry = true;
                return;
            }

            if (response.Result != null)
            {
                var value = CompareExchangeValueResultParser <BlittableJsonReaderObject> .GetValue((BlittableJsonReaderObject)response.Result, materializeMetadata : false, _conventions);

                if (_clusterSession._session.NoTracking)
                {
                    if (value == null)
                    {
                        Result = _clusterSession.RegisterMissingCompareExchangeValue(_key).GetValue <T>(_conventions);
                        return;
                    }

                    Result = _clusterSession.RegisterCompareExchangeValue(value).GetValue <T>(_conventions);
                    return;
                }

                if (value != null)
                {
                    _clusterSession.RegisterCompareExchangeValue(value);
                }
            }

            if (_clusterSession.IsTracked(_key) == false)
            {
                _clusterSession.RegisterMissingCompareExchangeValue(_key);
            }

            Result = _clusterSession.GetCompareExchangeValueFromSessionInternal <T>(_key, out var notTracked);
            Debug.Assert(_clusterSession._session.NoTracking || notTracked == false, "notTracked == false");
        }