本文整理汇总了C#中RedisClient.Del方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.Del方法的具体用法?C# RedisClient.Del怎么用?C# RedisClient.Del使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedisClient
的用法示例。
在下文中一共展示了RedisClient.Del方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDel
public void TestDel()
{
using(var mock = new MockConnector("localhost", 9999, ":3\r\n"))
using(var redis = new RedisClient(mock))
{
Assert.Equal(3, redis.Del("test"));
Assert.Equal("*2\r\n$3\r\nDEL\r\n$4\r\ntest\r\n", mock.GetMessage());
}
this.RealCall(redis =>
{
redis.MSet(new RedisDictionary { { "key1", "value1" }, { "key2", "value2" } });
Assert.Equal(2, redis.Del("key1", "key2"));
});
}
示例2: 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;
}
示例3: Delete
public void Delete(Tile tile)
{
var client = new RedisClient();
client.Del(new TileKeys().GetTileKey(tile.Id));
new DataIdManager ().Remove (tile);
}
示例4: Delete
public void Delete(Guid personId)
{
var client = new RedisClient ();
var key = new PeopleKeys ().GetPersonKey (personId);
if (client.Exists (key))
client.Del (key);
}
示例5: TestDel
public void TestDel()
{
using (var mock = new FakeRedisSocket(":3\r\n"))
using (var redis = new RedisClient(mock, new DnsEndPoint("fakehost", 9999)))
{
Assert.AreEqual(3, redis.Del("test"));
Assert.AreEqual("*2\r\n$3\r\nDEL\r\n$4\r\ntest\r\n", mock.GetMessage());
}
}
示例6: Can_change_db_at_runtime
public void Can_change_db_at_runtime()
{
using (var redis = new RedisClient(TestConfig.SingleHost, TestConfig.RedisPort, db: 1))
{
var val = Environment.TickCount;
var key = "test" + val;
try
{
redis.Set(key, val);
redis.ChangeDb(2);
Assert.That(redis.Get<int>(key), Is.EqualTo(0));
redis.ChangeDb(1);
Assert.That(redis.Get<int>(key), Is.EqualTo(val));
redis.Dispose();
}
finally
{
redis.ChangeDb(1);
redis.Del(key);
}
}
}
示例7: RedisTestKeys
public RedisTestKeys(RedisClient redis, params string[] keys)
{
_redis = redis;
_keys = keys;
_redis.Del(keys);
}
示例8: Run
public override void Run()
{
var personnels = Personnel.GetSamplePersonnels();
var client = new RedisClient();
var listKey = "personnels";
// setup sample data
client.Pipeline(c =>
{
client.Del(listKey);
foreach (var person in personnels) {
var idStr = person.Id.ToString();
c.LPush(listKey, idStr);
c.HSet(idStr, "name", person.Name);
c.HSet(idStr, "email", person.Email);
c.HIncrBy(idStr, "age", person.Age);
c.HIncrBy(idStr, "salary", person.Salary);
c.HSet(idStr, "json", person.ToJson());
}
});
while (true) {
WriteLine("0. List personnels sorted by yearly income.");
WriteLine("1. List personnels sorted by age.");
WriteLine("2. List personnels sorted by id descending.");
WriteLine("3. List personnels sorted by name.");
WriteLine("4. List all personnel emails.");
string[] result;
var parseResult = true;
switch (ReadLine()) {
case "0": {
result = client.Sort(listKey,
byPattern: "*->salary",
getPattern: new[] { "*->json" });
} break;
case "1": {
parseResult = true;
result = client.Sort(listKey,
byPattern: "*->age",
getPattern: new[] { "*->json" });
} break;
case "2": {
parseResult = true;
result = client.Sort(listKey,
descending: true,
getPattern: new[] { "*->json" });
} break;
case "3": {
result = client.Sort(listKey,
byPattern: "*->name",
alpha: true,
getPattern: new[] { "*->json" });
} break;
case "4": {
result = client.Sort(listKey,
byPattern: "nosort", // non-existent key
getPattern: new[] { "*->email" });
parseResult = false;
} break;
default: continue;
}
if (parseResult)
result = result
.Select(json => Personnel.FromJson(json).ToString())
.ToArray();
WriteLine("\r\nResults:");
Array.ForEach(result, WriteLine);
WriteLine("\r\n");
}
}