Beispiel #1
0
        public string GetAndUpdate(string partitionId, string objectId, ReadAdvancedResponse response = null)
        {
            Console.WriteLine("Get and update");

            ReadAdvancedResponse req = null;
            var obj = new PartitionObject(partitionId, objectId);

            if (_previousValues.TryGetValue(obj, out req))
            {
                if (response == null)
                {
                    return(req.ObjectValue);
                }

                if (req.Timestamp <= response.Timestamp)
                {
                    _previousValues[obj] = response;
                    return(response.ObjectValue);
                }

                return(req.ObjectValue);
            }
            else
            {
                if (response == null)
                {
                    return(_service.ObjectNotPresent);
                }

                _previousValues.Add(obj, response);
                return(response.ObjectValue);
            }
        }
Beispiel #2
0
        public void WriteToCache(string partitionId, string objectId, string objectValue, int timestamp)
        {
            ReadAdvancedResponse req = null;
            var r = new ReadAdvancedResponse {
                ObjectValue = objectValue, Timestamp = timestamp
            };
            var obj = new PartitionObject(partitionId, objectId);

            if (!_previousValues.TryGetValue(obj, out req))
            {
                _previousValues.Add(obj, r);
            }
            else
            {
                _previousValues[obj] = r;
            }
        }
Beispiel #3
0
 public bool Equals(PartitionObject other)
 {
     return(partitionId.Equals(partitionId) && objectId.Equals(other.objectId));
 }