Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        public void RoundTripRedisValue(RedisValue value)
        {
            var boxed   = value.Box();
            var unboxed = RedisValue.Unbox(boxed);

            AssertEqualGiveOrTakeNaN(value, unboxed);
        }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 protected override void Set(int database, RedisKey key, RedisValue value)
 => _cache[key] = value.Box();