Showing posts with label Cache. Show all posts
Showing posts with label Cache. Show all posts

Memcached c# simple example

github link Install using nuget
PM> Install-Package EnyimMemcached
            MemcachedClientConfiguration config = new MemcachedClientConfiguration();
            IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse(""), 11211);
            config.Protocol = MemcachedProtocol.Text;

            //using - not recommended here, check out documentation
            using (var mc = new MemcachedClient(config))
                var zz = mc.Get("test_" + x);

                mc.Store(StoreMode.Set, "Test", "Hello World");

simple example reddis c#

1 Download MSI from here

2 Install nuget package in your project

3 How to use

using StackExchange.Redis;
            using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(""))
                IDatabase cache = redis.GetDatabase();

                cache.StringSet("key1", "value");
                cache.StringSet("key2", 25);

                string key1 = cache.StringGet("key1");
                int key2 = (int)cache.StringGet("key2");