|
|
|
@ -30,7 +30,7 @@ namespace RedisStudyTest
|
|
|
|
|
private Student defaultStudent = null;
|
|
|
|
|
private string preStudentHashKey = "RedisStudy:Student:";
|
|
|
|
|
private string defaultStudentHashKey = "";
|
|
|
|
|
private int keyDefaultExpireSeconds = 20;
|
|
|
|
|
private int defaultExpireSeconds = 20;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造
|
|
|
|
@ -159,7 +159,7 @@ namespace RedisStudyTest
|
|
|
|
|
Assert.True(addHash);
|
|
|
|
|
|
|
|
|
|
//设置过期
|
|
|
|
|
redisDatabase.KeyExpire(defaultStudentHashKey, TimeSpan.FromSeconds(keyDefaultExpireSeconds));
|
|
|
|
|
redisDatabase.KeyExpire(defaultStudentHashKey, TimeSpan.FromSeconds(defaultExpireSeconds));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -184,7 +184,7 @@ namespace RedisStudyTest
|
|
|
|
|
Assert.True(addStudent);
|
|
|
|
|
|
|
|
|
|
//设置过期
|
|
|
|
|
redisDatabase.KeyExpire(redisKey, TimeSpan.FromSeconds(keyDefaultExpireSeconds));
|
|
|
|
|
redisDatabase.KeyExpire(redisKey, TimeSpan.FromSeconds(defaultExpireSeconds));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//清理删除
|
|
|
|
@ -498,7 +498,7 @@ namespace RedisStudyTest
|
|
|
|
|
{
|
|
|
|
|
AddDefaultStudent();
|
|
|
|
|
|
|
|
|
|
RedisValue[] hashFields = new RedisValue[]
|
|
|
|
|
RedisValue[] hashFields = new RedisValue[]
|
|
|
|
|
{
|
|
|
|
|
"Id",
|
|
|
|
|
"Name",
|
|
|
|
@ -631,9 +631,9 @@ namespace RedisStudyTest
|
|
|
|
|
{
|
|
|
|
|
//插入多列hash
|
|
|
|
|
List<HashEntry> hashEntries = new List<HashEntry>();
|
|
|
|
|
for (int i=1;i<=100; i++)
|
|
|
|
|
for (int i = 1; i <= 100; i++)
|
|
|
|
|
{
|
|
|
|
|
hashEntries.Add(new HashEntry("Field"+i,i));
|
|
|
|
|
hashEntries.Add(new HashEntry("Field" + i, i));
|
|
|
|
|
}
|
|
|
|
|
redisHashStudy.HashSet(defaultStudentHashKey, hashEntries.ToArray());
|
|
|
|
|
|
|
|
|
@ -708,7 +708,7 @@ namespace RedisStudyTest
|
|
|
|
|
[Fact]
|
|
|
|
|
public void HashDeleteNotFieldTest()
|
|
|
|
|
{
|
|
|
|
|
redisHashStudy.HashIncrement(defaultStudentHashKey, "Id",1);
|
|
|
|
|
redisHashStudy.HashIncrement(defaultStudentHashKey, "Id", 1);
|
|
|
|
|
|
|
|
|
|
var hashDeleteResult = redisHashStudy.HashDelete(defaultStudentHashKey, "Name");
|
|
|
|
|
Assert.False(hashDeleteResult);
|
|
|
|
@ -740,14 +740,14 @@ namespace RedisStudyTest
|
|
|
|
|
{
|
|
|
|
|
AddDefaultStudent();
|
|
|
|
|
|
|
|
|
|
RedisValue[] delValues = new RedisValue[]
|
|
|
|
|
RedisValue[] delValues = new RedisValue[]
|
|
|
|
|
{
|
|
|
|
|
"Id",
|
|
|
|
|
"Name",
|
|
|
|
|
"Age",
|
|
|
|
|
};
|
|
|
|
|
var hashDeleteResult = redisHashStudy.HashDelete(defaultStudentHashKey, delValues, CommandFlags.None);
|
|
|
|
|
Assert.Equal(3,hashDeleteResult);
|
|
|
|
|
Assert.Equal(3, hashDeleteResult);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|