public IDictionary <RedisKey, MockRedisValueWithExpiry> GetDbWithExpiry() { Dictionary <RedisKey, MockRedisValueWithExpiry> dict = new Dictionary <RedisKey, MockRedisValueWithExpiry>(); var database = GetDatabase(); foreach (RedisKey key in GetKeys()) { string stringKey = key; stringKey = stringKey.Substring(ContentLocationStoreFactory.DefaultKeySpace.Length); RedisKey redisKey = stringKey; redisKey = redisKey.Prepend(ContentLocationStoreFactory.DefaultKeySpace); if (!dict.ContainsKey(redisKey)) { var type = database.KeyType(key); if (type != RedisType.String) { continue; } var valueWithExpiry = database.StringGetWithExpiry(key); DateTime?expiryDate; if (valueWithExpiry.Expiry == null) { expiryDate = null; } else if (valueWithExpiry.Expiry.Value == default(TimeSpan)) { expiryDate = null; } else { expiryDate = _clock.UtcNow + valueWithExpiry.Expiry; } dict[redisKey] = new MockRedisValueWithExpiry(valueWithExpiry.Value, expiryDate); } } return(dict); }
public override bool Equals(object obj) { MockRedisValueWithExpiry other = obj as MockRedisValueWithExpiry; if (other == null) { return(base.Equals(obj)); } else { if (!Value.Equals(other.Value)) { return(false); } if (Expiry == null ^ other.Expiry == null) { return(false); } if (Expiry == null) { return(true); } if (Expiry.Value >= other.Expiry.Value && (Expiry.Value - other.Expiry.Value < ThresholdForExpiry)) { return(true); } if (Expiry.Value < other.Expiry.Value && (other.Expiry.Value - Expiry.Value < ThresholdForExpiry)) { return(true); } return(false); } }