Ejemplo n.º 1
0
        public void ObjectStore()
        {
            var client = MemcachedHelper.CreateClient(new MessagePackMapTranscoder());

            GetReadCache().Clear();
            GetWriteCache().Clear();

            client.Store(StoreMode.Add, "objKey", new MyClass {
                MyProperty = 10, MyProperty2 = "test"
            }).Is(true);
            client.Get("objKey").IsNotNull();
            (client.Get("objKey") as MyClass).Is(x => x.MyProperty == 10 && x.MyProperty2 == "test");
            client.Get <MyClass>("objKey").Is(x => x.MyProperty == 10 && x.MyProperty2 == "test");

            client.Store(StoreMode.Add, "genKey", new GenericType <int> {
                MyProperty = 10, MyProperty2 = 100
            }).Is(true);
            client.Get <GenericType <int> >("genKey").Is(x => x.MyProperty == 10 && x.MyProperty2 == 100);

            client.Store(StoreMode.Add, "genKey2", new GenericType <string> {
                MyProperty = 10, MyProperty2 = "hyaku"
            }).Is(true);
            client.Get <GenericType <string> >("genKey2").Is(x => x.MyProperty == 10 && x.MyProperty2 == "hyaku");

            GetReadCache().Count.Is(3);
            GetWriteCache().Count.Is(3);
        }
Ejemplo n.º 2
0
        public void CollectionStore()
        {
            var client = MemcachedHelper.CreateClient(new MessagePackMapTranscoder());

            GetReadCache().Clear();
            GetWriteCache().Clear();

            client.Store(StoreMode.Add, "listKey", new List <int> {
                0, 1, 2, 3
            }).Is(true);
            client.Get <List <int> >("listKey").Is(0, 1, 2, 3);

            client.Store(StoreMode.Add, "arrayKey", new int[] { 1, 2, 3 }).Is(true);
            client.Get <int[]>("arrayKey").Is(1, 2, 3);

            client.Store(StoreMode.Add, "arrayKey2", new int[] { 1, 2, 3, 4, 5 }).Is(true);
            client.Get <int[]>("arrayKey2").Is(1, 2, 3, 4, 5);

            var values = client.Get(new[] { "listKey", "arrayKey", "arrayKey2" });

            (values["listKey"] as List <int>).Is(0, 1, 2, 3);
            (values["arrayKey"] as int[]).Is(1, 2, 3);
            (values["arrayKey2"] as int[]).Is(1, 2, 3, 4, 5);

            GetReadCache().Count.Is(2);
            GetWriteCache().Count.Is(2);
        }
Ejemplo n.º 3
0
        public void MemcachedCheck()
        {
            var client = MemcachedHelper.CreateClient(new MessagePackMapTranscoder());
            var store  = client.Store(StoreMode.Add, "hugahuga", 100);

            store.Is(true);

            var value = client.Get <int>("hugahuga");

            value.Is(100);
        }
Ejemplo n.º 4
0
        public void Init()
        {
            var client = MemcachedHelper.CreateClient(new MessagePackMapTranscoder());

            client.FlushAll();
        }
        public void Init()
        {
            var client = MemcachedHelper.CreateClient(new ProtoTranscoder());

            client.FlushAll();
        }