serialize/deserialize arbitrary objects (objects must be serializable)
Inheritance: ISerializer
		public void Can_serialize_object_with_default_serializer()
		{
		     var ser = new ObjectSerializer();
		     string test = "test";
		     var serialized = ser.Serialize(test);
             Assert.AreEqual(test, ser.Deserialize(serialized));
		}
Example #2
0
        static void simpleRedisGetSet()
        {
            string host = "localhost";
            string elementKey = "testKeyRedis";
            RedisClient redisclient = new RedisClient(host);
            redisclient.Remove(elementKey);
            var storeMembers = new List<string> { "asd","dsd","bb"};
            // storeMembers.ForEach(x=>redisclient.AddItemToList(elementKey,x));

            redisclient.AddRangeToList(elementKey,storeMembers);
            var members = redisclient.GetAllItemsFromList(elementKey);
            var list = redisclient.Lists[elementKey];
            list.Clear();
            var ser = new ObjectSerializer();
            bool result = redisclient.Set<byte[]>(elementKey, ser.Serialize(storeMembers));
            if (result)
            {
                var resultlist = ser.Deserialize(redisclient.Get<byte[]>(elementKey));
            }
            members.ForEach(s=>Console.WriteLine("list:"+s));
             //   Console.WriteLine("index2:"+redisclient.GetItemFromList(elementKey,1));
            //if (redisclient.Get<string>(elementKey) == null)
            //{
            //    redisclient.Set(elementKey, "defaultValue");
            //}
            //else {
            //    redisclient.Set(elementKey, "new default value");
            //}
            //Console.WriteLine("redise:value:"+redisclient.Get<string>(elementKey));
            Console.WriteLine(redisclient.Info);
        }