Example #1
0
        public void _0_TestDBInsert_2()
        {
#pragma warning disable CS0219 // Variable is assigned but its value is never used
            string appId, filename, password;
#pragma warning restore CS0219 // Variable is assigned but its value is never used
            appId    = "memstache.demo";
            filename = "MemstacheTest.cv";
            password = "******";
            string key = "test02";

            StacheMeister meister = new StacheMeister("memstache.demo");
            //StacheMeister meister = new StacheMeister(appId, filename, password);

            // var rowcount = Meister.DB.Delete<Stash>(key);
            StashRepo.Delete(key);
            Stasher stash = meister.MakeStasher("test", StashPlan.spSerialize);
            string  s     = "another test";
            s = JsonConvert.SerializeObject(s);

            stash.DbAddOrUpdate(new Stash()
            {
                Key = key, Value = s, Serialized = true
            });

            // stash.DB.Insert(new Stash() { key = key,  value = s, serialized=true });
            Task.Delay(1000);
            Stash result = stash.DbGet(key);
            Console.WriteLine("Payload Test: {0}", result.Value);
        }
Example #2
0
        public void _0_TestStasher()
        {
            string        key     = "test01";
            StacheMeister meister = new StacheMeister("memstache.demo");

            // var rowcount = Meister.DB.Delete<Stash>(key);
            StashRepo.Delete(key);
            Stasher stash = meister.MakeStasher("test", StashPlan.spSerialize);

            Console.WriteLine("MemStache Initialized: {0}", stash.Purpose);

            var payload = new Stash()
            {
                Key = key, Object = "This is a test"
            };

            var hash1 = Stasher.Hash(payload.Value);

            stash[key] = payload;

            payload.Value = string.Empty;

            payload = stash[key];

            Console.WriteLine("Payload Test: {0}", payload.Value);

            var hash2 = Stasher.Hash(payload.Value);

            Assert.AreEqual(hash1, hash2);
        }
Example #3
0
        public void _3_StasherSerializeAndCompressAndEncrypt()
        {
            string        key     = "test05";
            StacheMeister meister = new StacheMeister("memstache.demo");

            // var rowcount = Meister.DB.Delete<Stash>(key);
            StashRepo.Delete(key);
            Stasher stash = meister.MakeStasher("test", StashPlan.spProtectCompress);

            Console.WriteLine("MemStache Initialized: {0}", stash.Purpose);

            Valuation valuation1 = new Valuation();

            var payload = new Stash()
            {
                Key = key, StashPlan = StashPlan.spProtectCompress, Object = valuation1
            };
            var typeName = payload.StoredType;

            var hash1 = Stasher.Hash(payload.Value);

            stash[key] = payload;

            // payload.value = "";
            if (payload == null)
            {
                Console.WriteLine("Payload is nulls");
            }

            payload = stash[key];

            Valuation valuation2 = payload.Object as Valuation;

            Console.WriteLine("Payload Test: {0}", payload.Value);

            var hash2 = Stasher.Hash(payload.Value);

            Assert.AreEqual(hash1, hash2);
        }
Example #4
0
        public void _0_TestDBInsert()
        {
            string        key     = "test02";
            StacheMeister meister = new StacheMeister("memstache.demo");

            // var rowcount = Meister.DB.Delete<Stash>(key);
            StashRepo.Delete(key);
            Stasher stash = meister.MakeStasher("test", StashPlan.spSerialize);
            string  s     = "another test";

            s = JsonConvert.SerializeObject(s);

            stash.DbAddOrUpdate(new Stash()
            {
                Key = key, Value = s, Serialized = true
            });

            // stash.DB.Insert(new Stash() { key = key,  value = s, serialized=true });
            Task.Delay(1000);
            Stash result = stash.DbGet(key);

            Console.WriteLine("Payload Test: {0}", result.Value);
        }