public void ReturnInternedBoxesForCommonValues(RedisValue value, bool expectSameReference) { object x = value.Box(), y = value.Box(); Assert.Equal(expectSameReference, ReferenceEquals(x, y)); // check we got the right values! AssertEqualGiveOrTakeNaN(value, RedisValue.Unbox(x)); AssertEqualGiveOrTakeNaN(value, RedisValue.Unbox(y)); }
public void RoundTripRedisValue(RedisValue value) { var boxed = value.Box(); var unboxed = RedisValue.Unbox(boxed); AssertEqualGiveOrTakeNaN(value, unboxed); }
public RedisPipeValue(PipeInfo pipeInfo, RedisValue redisValue, string batchHoldingList, bool peaked) { _redisValue = redisValue; _convertedValue = new Lazy <object>(() => { var value = _redisValue.Box(); var objectValue = value; return(objectValue); }); PipeInfo = pipeInfo; BatchHoldingList = batchHoldingList; Peaked = peaked; }
public RedisPipeValue(PipeInfo pipeInfo, RedisValue redisValue, string lockValue, bool peaked) { _redisValue = redisValue; _convertedValue = new Lazy <T>(() => { var value = _redisValue.Box(); var typedValue = (T)value; return(typedValue); }); PipeInfo = pipeInfo; LockValue = lockValue; Peaked = peaked; }
public static string ReadAsString(RedisValue value) { var boxedValue = value.Box(); if (boxedValue != null) { if (boxedValue is byte[] bytes) { return(Encoding.UTF8.GetString(bytes)); } else { return(boxedValue.ToString()); } } return(null); }
protected override void Set(int database, RedisKey key, RedisValue value) => _cache[key] = value.Box();