%name% -- name of service instance, ex. redis-instance;
%binpath% -- path to this project exe file, ex. C:\Program Files\Redis\RedisService_1.1.exe;
%configpath% -- path to redis configuration file, ex. C:\Program Files\Redis\redis.conf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ServiceStack.Redis;
using System.Threading;
namespace Zeus.Cache.Redis.Demo
{
public class SimpleRedisDemo
{
public void SimpleDemo()
{
string host = "localhost";
string elementKey = "testKeyRedis";
using (RedisClient redisClient = new RedisClient(host))
{
if (redisClient.Get(elementKey) == null)
{
// adding delay to see the difference
Thread.Sleep(2000);
// save value in cache
redisClient.Set(elementKey, "default value");
}
//change the value
redisClient.Set(elementKey, "fuck you value");
// get value from the cache by key
string message = "Item value is: " + redisClient.Get(elementKey);
Console.WriteLine(message);
}
}
}
}