本文整理汇总了C#中RedisClient.Set方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.Set方法的具体用法?C# RedisClient.Set怎么用?C# RedisClient.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedisClient
的用法示例。
在下文中一共展示了RedisClient.Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyTestMethod3
public void MyTestMethod3()
{
using(var mock = new MockConnector("localhost", 9999, "+OK\r\n", "+OK\r\n"))
using(var redis = new RedisClient(mock))
{
Assert.True(redis.Set("key", "value"));
Assert.Equal("*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n", mock.GetMessage());
Assert.True(redis.Set("key", "value"));
Assert.Equal("*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n", mock.GetMessage());
}
}
示例2: Save
public void Save(EngineInfo info)
{
var client = new RedisClient();
var key = new EngineKeys ().GetInfoKey (info.Id);
var json = info.ToJson ();
client.Set(key, json);
}
示例3: ValidateTransfer
public string ValidateTransfer(string sourceAppId, string userId, string transferId, string transferToken)
{
var red = new RedisClient<string>();
var result = red.Get("transfertoken:" + transferId);
if (!string.IsNullOrEmpty(result))
{
var redResult = red.Del("transfertoken:" + transferId);
var redapp = new RedisClient<AppRegistry>();
redapp.Select(1);
var app = redapp.Get(HttpContext.Current.Items["AppId"] as string);
var str = "UserId=" + userId + "&TransferId=" + transferId + "&Salt=" + app.AppSecret ;
str = Hash.GetHash(str, Hash.HashType.SHA256);
if (transferToken != str)
{
throw new FaultException<UnauthorizedAccessException>(new UnauthorizedAccessException("token yanlış"));
}
string sessionguid = Guid.NewGuid().ToString();
var redis = new RedisClient<Common.SessionRegistry>();
var appId = HttpContext.Current.Items["AppId"] as string;
redis.Set(sessionguid, new SessionRegistry() { SessionCookie = sessionguid, AppId = appId, UserId = userId });
return sessionguid;
}
return null;
}
示例4: Can_connect_to_ssl_azure_redis
public void Can_connect_to_ssl_azure_redis()
{
using (var client = new RedisClient(connectionString))
{
client.Set("foo", "bar");
var foo = client.GetValue("foo");
foo.Print();
}
}
示例5: GetTest
public void GetTest()
{
using (IRedisClient client = new RedisClient("localhost", ReidsDefaultTcpPort, 12))
{
Assert.IsTrue(client.Set("TestName2", "TestValue2"));
Assert.AreEqual(client.Get("TestName2"), "TestValue2");
Assert.IsTrue(client.Connected);
}
}
示例6: Can_connect_to_ssl_azure_redis_with_UrlFormat
public void Can_connect_to_ssl_azure_redis_with_UrlFormat()
{
var url = "redis://{0}?ssl=true&password={1}".Fmt(Host, Password.UrlEncode());
using (var client = new RedisClient(url))
{
client.Set("foo", "bar");
var foo = client.GetValue("foo");
foo.Print();
}
}
示例7: Save
public void Save(Person person)
{
var client = new RedisClient();
var key = new PeopleKeys ().GetPersonKey (person.Id);
var json = person.ToJson ();
client.Set(key, json);
var idManager = new DataIdManager ();
idManager.Add (person);
}
示例8: Del_key
public void Del_key()
{
using (var rcClient = new RedisClient(ip, port))
{
rcClient.Set("Set_Get_key", "Set_Get_key");
var reply = rcClient.DelKey("Set_Get_key");
Assert.AreEqual(reply, 1);
}
}
示例9: Save
public void Save(Tile tile, Building[] buildings)
{
var client = new RedisClient();
var json = ArrayToJson (buildings);
var key = new BuildingKeys ().GetBuildingsKey (tile.Id);
client.Set(key, json);
//var idManager = new DataIdManager ();
//idManager.Add (tile);
}
示例10: Save
public void Save(BaseInstruction instruction)
{
var client = new RedisClient();
var key = new InstructionKeys ().GetKey (instruction.Id);
var json = instruction.ToJson ();
client.Set(key, json);
var idManager = new InstructionIdManager ();
idManager.Add (instruction);
}
示例11: Set_Get_key
public void Set_Get_key()
{
var key = "Set_Get_key";
using (var rcClient = new RedisClient(ip, port))
{
rcClient.Set(key, key);
var info2 = rcClient.Get(key);
Assert.AreEqual(info2.ToString(), key);
}
}
示例12: Continuation_Set_Get_ByDifferentClient
public void Continuation_Set_Get_ByDifferentClient()
{
for (int i = 0; i < 1000; i++)
{
using (var rcClient = new RedisClient(ip, port))
{
rcClient.Set("Continuation_Set_Get_ByDifferentClient" + i, i.ToString(), 10);
rcClient.Get("Continuation_Set_Get_ByDifferentClient" + i);
rcClient.Send(RedisCommand.INFO);
}
}
}
示例13: SetUTF8Test
public void SetUTF8Test()
{
using (var mock = new FakeRedisSocket("+OK\r\n", "+OK\r\n"))
using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
{
Assert.AreEqual("OK", redis.Set("test", "é"));
Assert.AreEqual("*3\r\n$3\r\nSET\r\n$4\r\ntest\r\n$2\r\né\r\n", mock.GetMessage());
Assert.AreEqual("OK", redis.SetAsync("test", "é").Result);
Assert.AreEqual("*3\r\n$3\r\nSET\r\n$4\r\ntest\r\n$2\r\né\r\n", mock.GetMessage());
}
}
示例14: Search_Test
public void Search_Test()
{
using (var client = new RedisClient(TestConfig.SingleHost))
{
const string cacheKey = "urn+metadata:All:SearchProProfiles?SwanShinichi Osawa /0/8,0,0,0";
const long value = 1L;
client.Set(cacheKey, value);
var result = client.Get<long>(cacheKey);
Assert.That(result, Is.EqualTo(value));
}
}
示例15: Logon
public string Logon(string username, string password, string mode)
{
if (username == "mucit" && password == "endulus")
{
string sessionguid = Guid.NewGuid().ToString();
var redis = new RedisClient<Common.SessionRegistry>();
var appId = HttpContext.Current.Items["AppId"] as string;
redis.Set(sessionguid, new SessionRegistry() {SessionCookie=sessionguid, AppId=appId, UserId=username});
return sessionguid;
}
else throw new FaultException<UnauthorizedAccessException>(new UnauthorizedAccessException("şifre yanlış"));
}