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); } }
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; } }
public bool Equals(PartitionObject other) { return(partitionId.Equals(partitionId) && objectId.Equals(other.objectId)); }