using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StackExchange.Redis;
namespace StackExchangeRedisDemo
{
class Program
{
static void Main(string[] args)
{
ConnectionMultiplexer connection = ConnectionMultiplexer.Connect(“10.10.10.201”);
var db = connection.GetDatabase(0);
db.StringSet(“100101:stringKey”, “stringValue”, TimeSpan.FromMilliseconds(10));
db.StringGet(“100101:stringKey”);
db.StringIncrement(“100101:stringInt”);
db.ListLeftPush("100101:listTest", "abc");
db.ListLeftPush("100101:listTest", new[] {"bcd", "abc", "acd", "bca"}.Select(i => (RedisValue) i).ToArray());
db.ListRange("100101:listTest");
db.HashSet("100101:hashTest", new[] {new HashEntry("field0", "value0"), new HashEntry("field1", 1)});
db.HashGetAll("100101:hashTest");
db.HashIncrement("100101:hashTest", "field1");
db.SetAdd("100101:setTest", 1);
db.SetAdd("100101:setTest", new[] {1, 2, 5, 6, 9}.Select(i => (RedisValue) i).ToArray());
db.SetMembers("100101:setTest");
var batch = db.CreateBatch();
batch.StringSetAsync("100101:stringKey1", "test");
batch.SetAddAsync("100101:setTest1", "123");
var taskBatch = batch.HashGetAllAsync("100101:hashTest");
batch.Execute();
var entries = taskBatch.Result;
Console.WriteLine(entries.Length);
var transaction = db.CreateTransaction();
transaction.HashIncrementAsync("100101:hashTest", "field1");
transaction.ListLeftPushAsync("100101:listTest", "bcde");
transaction.Execute();
}
}
}