feat: initial commit - HJHA game server full source
6 major server modules (PdkFriendServer/GlobalSever/ServerCore/GameModule/GameNetModule) + game logic (GameFix/GameDAL/ServerData) + network layer (NetWorkMessage) + data layer (ObjectModel) + utilities (MrWu/Core/Config/CloudAPI/dll) + adapters (zyxAdapter/base) .NET 8.0 C# solution, 16 projects, 958 source files
This commit is contained in:
314
GameDAL/db/redis/DistributedLock.cs
Normal file
314
GameDAL/db/redis/DistributedLock.cs
Normal file
@ -0,0 +1,314 @@
|
||||
/*
|
||||
* 由SharpDevelop创建。
|
||||
* 用户: Administrator
|
||||
* 日期: 2018-10-24
|
||||
* 时间: 9:56
|
||||
*
|
||||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
||||
*/
|
||||
using System;
|
||||
using System.Threading;
|
||||
using MrWu.Debug;
|
||||
using Server.DB.Redis;
|
||||
using StackExchange.Redis;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Server.DB.Redis
|
||||
{
|
||||
/// <summary>
|
||||
/// 分布式锁
|
||||
/// </summary>
|
||||
public class DistributedLock{
|
||||
|
||||
/// <summary>
|
||||
/// 最大等待数量
|
||||
/// </summary>
|
||||
private readonly int maxWaitCnt;
|
||||
|
||||
/// <summary>
|
||||
/// 锁的钥匙
|
||||
/// </summary>
|
||||
private readonly string[] lockKey;
|
||||
|
||||
/// <summary>
|
||||
/// 下一个锁的位置
|
||||
/// </summary>
|
||||
private int nextid = -1;
|
||||
|
||||
/// <summary>
|
||||
/// 读写锁
|
||||
/// </summary>
|
||||
private readonly ReaderWriterLockSlim rwls = new ReaderWriterLockSlim();
|
||||
|
||||
private volatile IDatabaseProxy m_db;
|
||||
|
||||
/// <summary>
|
||||
/// 操作线程锁数据库
|
||||
/// </summary>
|
||||
private IDatabaseProxy db{
|
||||
get{
|
||||
if(m_db == null)
|
||||
m_db = redisManager.db;
|
||||
return m_db;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建分布式锁
|
||||
/// </summary>
|
||||
/// <param name="waitMaxCnt">最大等待数量</param>
|
||||
public DistributedLock(int waitMaxCnt){
|
||||
maxWaitCnt = waitMaxCnt;
|
||||
lockKey = new string[maxWaitCnt];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加锁
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
private int AddKey(string key){
|
||||
while(true){
|
||||
rwls.EnterWriteLock();
|
||||
try{
|
||||
nextid++;
|
||||
if(nextid >= maxWaitCnt)
|
||||
nextid = 0;
|
||||
if(lockKey[nextid] == null){
|
||||
lockKey[nextid] = key;
|
||||
return nextid;
|
||||
}
|
||||
}finally{
|
||||
rwls.ExitWriteLock();
|
||||
}
|
||||
//SpinWait sw = new SpinWait();
|
||||
//sw.SpinOnce();
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除锁
|
||||
/// </summary>
|
||||
/// <param name="idx"></param>
|
||||
/// <returns></returns>
|
||||
private void RemoveKey(int idx){
|
||||
rwls.EnterWriteLock();
|
||||
try{
|
||||
lockKey[idx] = null;
|
||||
}finally{
|
||||
rwls.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取钥匙
|
||||
/// </summary>
|
||||
/// <param name="idx"></param>
|
||||
/// <returns></returns>
|
||||
private string GetKey(int idx){
|
||||
rwls.EnterReadLock();
|
||||
try{
|
||||
return lockKey[idx];
|
||||
}finally{
|
||||
rwls.ExitReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为锁续航
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
private void AddLockLife(object state){
|
||||
Task.Factory.StartNew(()=>{
|
||||
int idx = (int)state;
|
||||
string key = GetKey(idx);
|
||||
|
||||
while(true){
|
||||
Thread.Sleep(1000);
|
||||
if(key == GetKey(idx) && key != null){
|
||||
string strtimeOut = db.StringGet(key);
|
||||
if(strtimeOut != null){
|
||||
int timeOut;
|
||||
if(int.TryParse(strtimeOut,out timeOut))
|
||||
db.KeyExpire(key,new TimeSpan(0,0,timeOut));
|
||||
else
|
||||
Debug.Error("不可能的错误存储的值不是数字anckjnsakjbdnja,"+strtimeOut + "," + key);
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}else
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试运行
|
||||
/// </summary>
|
||||
/// <param name="key">key</param>
|
||||
/// <param name="action">事件</param>
|
||||
/// <param name="timeOut">key超时时间</param>
|
||||
/// <param name="tryTimeOut">尝试超时时间</param>
|
||||
/// <returns>是否运行</returns>
|
||||
public bool TryLockRun(string key,Action action,int timeOut,int tryTimeOut = 0){
|
||||
if(key == null){
|
||||
Debug.Error("key不能为null");
|
||||
return false;
|
||||
}
|
||||
key = key+".lock";
|
||||
TimeSpan tm = new TimeSpan(0,0,timeOut);
|
||||
DateTime lastTime = DateTime.Now;
|
||||
//SpinWait sw = new SpinWait();
|
||||
while(!db.StringSet(key,timeOut,tm,When.NotExists)){
|
||||
if((DateTime.Now - lastTime).TotalMilliseconds >= tryTimeOut)
|
||||
return false;
|
||||
//sw.SpinOnce();
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
||||
//Debug.Log("运算开始:" + key + "," + DateTime.Now.Millisecond.ToString());
|
||||
Exception ex = null;
|
||||
int idx = AddKey(key);
|
||||
try{
|
||||
AddLockLife(idx);
|
||||
if(action != null)
|
||||
action();
|
||||
}catch(Exception e){
|
||||
Debug.Error("处理出错:" + e.ToString());
|
||||
ex = e;
|
||||
}finally{
|
||||
RemoveKey(idx);
|
||||
//Debug.Log("运算结束:" + key + "," + DateTime.Now.Millisecond.ToString());
|
||||
db.KeyDelete(key);
|
||||
if(ex != null)
|
||||
throw ex;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试运行
|
||||
/// </summary>
|
||||
/// <param name="key">key</param>
|
||||
/// <param name="func">事件</param>
|
||||
/// <param name="timeOut">timeOut</param>
|
||||
/// <param name="result">返回结果</param>
|
||||
/// <param name="tryTimeOut">尝试超时时间</param>
|
||||
/// <returns>是否运行</returns>
|
||||
public bool TryLockRun<T>(string key,Func<T> func,int timeOut,out T result,int tryTimeOut = 0){
|
||||
result = default(T);
|
||||
if(key == null){
|
||||
Debug.Error("key不能为null");
|
||||
return false;
|
||||
}
|
||||
|
||||
key = key + ".lock";
|
||||
TimeSpan tm = new TimeSpan(0,0,timeOut);
|
||||
DateTime lastTime = DateTime.Now;
|
||||
//SpinWait sw = new SpinWait();
|
||||
while(!db.StringSet(key,timeOut,tm,When.NotExists)){
|
||||
if((DateTime.Now - lastTime).TotalMilliseconds >= tryTimeOut)
|
||||
return false;
|
||||
//sw.SpinOnce();
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
||||
Exception ex = null;
|
||||
int idx = AddKey(key);
|
||||
try{
|
||||
AddLockLife(idx);
|
||||
if(func != null)
|
||||
result = func();
|
||||
}catch(Exception e){
|
||||
ex = e;
|
||||
Debug.Error("处理出错:" + e.ToString());
|
||||
}finally{
|
||||
RemoveKey(idx);
|
||||
Debug.Log("运算结束:" + key + "," + DateTime.Now.Millisecond.ToString());
|
||||
db.KeyDelete(key);
|
||||
if(ex != null)
|
||||
throw ex;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加锁运行
|
||||
/// </summary>
|
||||
public void LockRun(string key,Action action,int timeOut = 3){
|
||||
if(key == null){
|
||||
Debug.Error("key不能为null");
|
||||
return;
|
||||
}
|
||||
key = key+".lock";
|
||||
TimeSpan tm = new TimeSpan(0,0,timeOut);
|
||||
//SpinWait sw = new SpinWait();
|
||||
while(!db.StringSet(key,timeOut,tm,When.NotExists)){
|
||||
//sw.SpinOnce();
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
||||
Exception ex = null;
|
||||
|
||||
int idx = AddKey(key);
|
||||
try{
|
||||
AddLockLife(idx);
|
||||
|
||||
if(action != null)
|
||||
action();
|
||||
|
||||
}catch(Exception e){
|
||||
ex = e;
|
||||
}finally{
|
||||
RemoveKey(idx);
|
||||
db.KeyDelete(key);
|
||||
if(ex != null)
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加锁运行
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="func"></param>
|
||||
/// <param name="timeOut">超时时间</param>
|
||||
/// <returns></returns>
|
||||
public T LockRun<T>(string key,Func<T> func,int timeOut = 3){
|
||||
T result = default(T);
|
||||
if(key == null){
|
||||
Debug.Error("key不能为null");
|
||||
return result;
|
||||
}
|
||||
|
||||
key = key + ".lock";
|
||||
TimeSpan tm = new TimeSpan(0,0,timeOut);
|
||||
//SpinWait sw = new SpinWait();
|
||||
|
||||
while(!db.StringSet(key,timeOut,tm,When.NotExists)){
|
||||
//sw.SpinOnce();
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
||||
Exception ex = null;
|
||||
int idx = AddKey(key);
|
||||
try{
|
||||
AddLockLife(idx);
|
||||
|
||||
if(func != null)
|
||||
result = func();
|
||||
|
||||
}catch(Exception e){
|
||||
ex = new Exception("lockRun error :" , e);
|
||||
}finally{
|
||||
RemoveKey(idx);
|
||||
db.KeyDelete(key);
|
||||
if(ex != null)
|
||||
throw ex;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
3622
GameDAL/db/redis/IDatabaseProxy.cs
Normal file
3622
GameDAL/db/redis/IDatabaseProxy.cs
Normal file
@ -0,0 +1,3622 @@
|
||||
/*
|
||||
* 由SharpDevelop创建。
|
||||
* 用户: Administrator
|
||||
* 日期: 2018-12-07
|
||||
* 时间: 15:34
|
||||
*
|
||||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
||||
*/
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MrWu.Debug;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Server.DB.Redis {
|
||||
/*
|
||||
* CommandFlags
|
||||
* None = 0; //默认行为
|
||||
* HighPriority = 1; //不用了,废弃
|
||||
* FireAndForget = 2; //对结果不感兴趣,调用者将会立即收到默认值
|
||||
* PreferMaster = 0; //如果主服务器可用,则应在主服务器上执行此操作,但可以执行读操作
|
||||
* DemandMaster = 4; //此操作只应在[主站]上执行
|
||||
* PreferSlave = 8; //如果可用,则应在[从站]上执行此操作,但将在其上执行
|
||||
* DemandSlave = 12; //此操作只应在[从站]上执行。 仅适用于读取操作。
|
||||
* NoRedirect = 64; //表示由于ASK或MOVED响应,不应将此操作转发到其他服务器
|
||||
* NoScriptCache = 512 //表示与脚本相关的操作应使用EVAL,而不是SCRIPT LOAD + EVALSHA
|
||||
* */
|
||||
|
||||
/*
|
||||
* When
|
||||
* Always: 一直
|
||||
* Exists: 当key存在时才生效
|
||||
* NotExists: 当key不存在时才生效
|
||||
*
|
||||
* */
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// IDatabase 代理
|
||||
/// </summary>
|
||||
public partial class IDatabaseProxy {
|
||||
|
||||
private IDatabase db;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="db"></param>
|
||||
public IDatabaseProxy(IDatabase db) {
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 循环超时数量
|
||||
/// </summary>
|
||||
private const int loopOutCnt = 3;
|
||||
|
||||
private T FDBOpera<T, K1>(Func<K1, T> func, K1 param1) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return func(param1);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private T FDBOpera<T, K1, K2>(Func<K1, K2, T> func, K1 param1, K2 param2) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return func(param1, param2);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private T FDBOpera<T, K1, K2, K3>(Func<K1, K2, K3, T> func, K1 param1, K2 param2, K3 param3) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return func(param1, param2, param3);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private T FDBOpera<T, K1, K2, K3, K4>(Func<K1, K2, K3, K4, T> func, K1 param1, K2 param2, K3 param3, K4 param4) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return func(param1, param2, param3, param4);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private T FDBOpera<T, K1, K2, K3, K4, K5>(Func<K1, K2, K3, K4, K5, T> func, K1 param1, K2 param2, K3 param3, K4 param4, K5 param5) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return func(param1, param2, param3, param4, param5);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private T FDBOpera<T, K1, K2, K3, K4, K5, K6>(Func<K1, K2, K3, K4, K5, K6, T> func, K1 param1, K2 param2, K3 param3, K4 param4, K5 param5, K6 param6) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return func(param1, param2, param3, param4, param5, param6);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private T FDBOpera<T, K1, K2, K3, K4, K5, K6, K7>(Func<K1, K2, K3, K4, K5, K6, K7, T> func, K1 param1, K2 param2, K3 param3, K4 param4, K5 param5, K6 param6, K7 param7) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return func(param1, param2, param3, param4, param5, param6, param7);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private T FDBOpera<T, K1, K2, K3, K4, K5, K6, K7, K8>(Func<K1, K2, K3, K4, K5, K6, K7, K8, T> func, K1 param1, K2 param2, K3 param3, K4 param4, K5 param5, K6 param6, K7 param7, K8 param8) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return func(param1, param2, param3, param4, param5, param6, param7, param8);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private T FDBOpera<T, K1, K2, K3, K4, K5, K6, K7, K8, K9>(Func<K1, K2, K3, K4, K5, K6, K7, K8, K9, T> func, K1 param1, K2 param2, K3 param3, K4 param4, K5 param5, K6 param6, K7 param7, K8 param8, K9 param9) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return func(param1, param2, param3, param4, param5, param6, param7, param8, param9);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ADBOpera<K1, K2, K3>(Action<K1, K2, K3> action, K1 param1, K2 param2, K3 param3) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
action(param1, param2, param3);
|
||||
return;
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 异步重试方法
|
||||
|
||||
private async Task<T> FDBOperaAsync<T, K1>(Func<K1, Task<T>> func, K1 param1) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return await func(param1);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<T> FDBOperaAsync<T, K1, K2>(Func<K1, K2, Task<T>> func, K1 param1, K2 param2) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return await func(param1, param2);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<T> FDBOperaAsync<T, K1, K2, K3>(Func<K1, K2, K3, Task<T>> func, K1 param1, K2 param2, K3 param3) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return await func(param1, param2, param3);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<T> FDBOperaAsync<T, K1, K2, K3, K4>(Func<K1, K2, K3, K4, Task<T>> func, K1 param1, K2 param2, K3 param3, K4 param4) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return await func(param1, param2, param3, param4);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<T> FDBOperaAsync<T, K1, K2, K3, K4, K5>(Func<K1, K2, K3, K4, K5, Task<T>> func, K1 param1, K2 param2, K3 param3, K4 param4, K5 param5) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return await func(param1, param2, param3, param4, param5);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<T> FDBOperaAsync<T, K1, K2, K3, K4, K5, K6>(Func<K1, K2, K3, K4, K5, K6, Task<T>> func, K1 param1, K2 param2, K3 param3, K4 param4, K5 param5, K6 param6) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return await func(param1, param2, param3, param4, param5, param6);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<T> FDBOperaAsync<T, K1, K2, K3, K4, K5, K6, K7>(Func<K1, K2, K3, K4, K5, K6, K7, Task<T>> func, K1 param1, K2 param2, K3 param3, K4 param4, K5 param5, K6 param6, K7 param7) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return await func(param1, param2, param3, param4, param5, param6, param7);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<T> FDBOperaAsync<T, K1, K2, K3, K4, K5, K6, K7, K8>(Func<K1, K2, K3, K4, K5, K6, K7, K8, Task<T>> func, K1 param1, K2 param2, K3 param3, K4 param4, K5 param5, K6 param6, K7 param7, K8 param8) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return await func(param1, param2, param3, param4, param5, param6, param7, param8);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<T> FDBOperaAsync<T, K1, K2, K3, K4, K5, K6, K7, K8, K9>(Func<K1, K2, K3, K4, K5, K6, K7, K8, K9, Task<T>> func, K1 param1, K2 param2, K3 param3, K4 param4, K5 param5, K6 param6, K7 param7, K8 param8, K9 param9) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
return await func(param1, param2, param3, param4, param5, param6, param7, param8, param9);
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ADBOperaAsync<K1, K2, K3>(Func<K1, K2, K3, Task> func, K1 param1, K2 param2, K3 param3) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
await func(param1, param2, param3);
|
||||
return;
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ADBOperaAsync<K1, K2, K3, K4>(Func<K1, K2, K3, K4, Task> func, K1 param1, K2 param2, K3 param3, K4 param4) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
await func(param1, param2, param3, param4);
|
||||
return;
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ADBOperaAsync<K1, K2, K3, K4, K5, K6>(Func<K1, K2, K3, K4, K5, K6, Task> func, K1 param1, K2 param2, K3 param3, K4 param4, K5 param5, K6 param6) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
await func(param1, param2, param3, param4, param5, param6);
|
||||
return;
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void ADBOpera<K1, K2, K3, K4>(Action<K1, K2, K3, K4> action, K1 param1, K2 param2, K3 param3, K4 param4) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
action(param1, param2, param3, param4);
|
||||
return;
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ADBOpera<K1, K2, K3, K4, K5, K6>(Action<K1, K2, K3, K4, K5, K6> action, K1 params1, K2 params2, K3 params3, K4 params4, K5 params5, K6 params6) {
|
||||
int cnt = 0;
|
||||
while(true) {
|
||||
try {
|
||||
action(params1, params2, params3, params4, params5, params6);
|
||||
return;
|
||||
} catch(TimeoutException) {
|
||||
cnt++;
|
||||
if(cnt > loopOutCnt) {
|
||||
Debug.Fatal("Redis 命令超时重试次数已达上限!");
|
||||
throw;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Debug.Fatal("redis错误:" + e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="asyncState"></param>
|
||||
/// <returns></returns>
|
||||
public IBatch CreateBatch(object asyncState = null) {
|
||||
return FDBOpera(db.CreateBatch, asyncState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="toServer"></param>
|
||||
/// <param name="toDatabase"></param>
|
||||
/// <param name="timeoutMilliseconds"></param>
|
||||
/// <param name="migrateOptions"></param>
|
||||
/// <param name="flags"></param>
|
||||
public void KeyMigrate(RedisKey key, EndPoint toServer, int toDatabase = 0, int timeoutMilliseconds = 0, MigrateOptions migrateOptions = MigrateOptions.None, CommandFlags flags = CommandFlags.None) {
|
||||
ADBOpera(db.KeyMigrate, key, toServer, toDatabase, timeoutMilliseconds, migrateOptions, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue DebugObject(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.DebugObject, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="longitude"></param>
|
||||
/// <param name="latitude"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool GeoAdd(RedisKey key, double longitude, double latitude, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.GeoAdd, key, longitude, latitude, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool GeoAdd(RedisKey key, GeoEntry value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.GeoAdd, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long GeoAdd(RedisKey key, GeoEntry[] values, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.GeoAdd, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool GeoRemove(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.GeoRemove, key, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member1"></param>
|
||||
/// <param name="member2"></param>
|
||||
/// <param name="unit"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public double? GeoDistance(RedisKey key, RedisValue member1, RedisValue member2, GeoUnit unit = GeoUnit.Meters, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.GeoDistance, key, member1, member2, unit, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="members"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public string[] GeoHash(RedisKey key, RedisValue[] members, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.GeoHash, key, members, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public string GeoHash(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.GeoHash, key, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="members"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public GeoPosition?[] GeoPosition(RedisKey key, RedisValue[] members, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.GeoPosition, key, members, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public GeoPosition? GeoPosition(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.GeoPosition, key, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="radius"></param>
|
||||
/// <param name="unit"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public GeoRadiusResult[] GeoRadius(RedisKey key, RedisValue member, double radius, GeoUnit unit = GeoUnit.Meters, int count = -1, Order? order = null, GeoRadiusOptions options = GeoRadiusOptions.Default, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.GeoRadius, key, member, radius, unit, count, order, options, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="longitude"></param>
|
||||
/// <param name="latitude"></param>
|
||||
/// <param name="radius"></param>
|
||||
/// <param name="unit"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public GeoRadiusResult[] GeoRadius(RedisKey key, double longitude, double latitude, double radius, GeoUnit unit = GeoUnit.Meters, int count = -1, Order? order = null, GeoRadiusOptions options = GeoRadiusOptions.Default, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.GeoRadius, key, longitude, latitude, radius, unit, count, order, options, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hash中作减法运算
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long HashDecrement(RedisKey key, RedisValue hashField, long value = 1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashDecrement, key, hashField, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hash中作减法运算
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public double HashDecrement(RedisKey key, RedisValue hashField, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashDecrement, key, hashField, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除一个Hash中的一个键
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>是否删除成功</returns>
|
||||
public bool HashDelete(RedisKey key, RedisValue hashField, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashDelete, key, hashField, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除hash中的一些键
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashFields"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>删除的数量</returns>
|
||||
public long HashDelete(RedisKey key, RedisValue[] hashFields, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashDelete, key, hashFields, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 某个Hash的键存在不存在
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool HashExists(RedisKey key, RedisValue hashField, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashExists, key, hashField, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取某个Hash的值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue HashGet(RedisKey key, RedisValue hashField, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashGet, key, hashField, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一堆Hash的值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashFields"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] HashGet(RedisKey key, RedisValue[] hashFields, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashGet, key, hashFields, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的Hash键值对
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public HashEntry[] HashGetAll(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashGetAll, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hash中的值做加法运算
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>运算后的结果</returns>
|
||||
public long HashIncrement(RedisKey key, RedisValue hashField, long value = 1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashIncrement, key, hashField, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hash中做加法运算
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public double HashIncrement(RedisKey key, RedisValue hashField, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashIncrement, key, hashField, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// hash的所有键
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] HashKeys(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashKeys, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hash中的键的数量
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long HashLength(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashLength, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pattern"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<HashEntry> HashScan(RedisKey key, RedisValue pattern, int pageSize, CommandFlags flags) {
|
||||
return FDBOpera(db.HashScan, key, pattern, pageSize, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pattern"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="cursor"></param>
|
||||
/// <param name="pageOffset"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<HashEntry> HashScan(RedisKey key, RedisValue pattern = default(RedisValue), int pageSize = 10, long cursor = 0L, int pageOffset = 0, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashScan, key, pattern, pageSize, cursor, pageOffset, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置一堆键值队.
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashFields"></param>
|
||||
/// <param name="flags"></param>
|
||||
public void HashSet(RedisKey key, HashEntry[] hashFields, CommandFlags flags = CommandFlags.None) {
|
||||
ADBOpera(db.HashSet, key, hashFields, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置Hash键值对
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="when">只能使用Always以及 NoeExists 表示是是Hash的key,而非redis的key</param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>是否设置成功</returns>
|
||||
public bool HashSet(RedisKey key, RedisValue hashField, RedisValue value, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashSet, key, hashField, value, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取hash的所有值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] HashValues(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HashValues, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool HyperLogLogAdd(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HyperLogLogAdd, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool HyperLogLogAdd(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HyperLogLogAdd, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long HyperLogLogLength(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HyperLogLogLength, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long HyperLogLogLength(RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.HyperLogLogLength, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="flags"></param>
|
||||
public void HyperLogLogMerge(RedisKey destination, RedisKey first, RedisKey second, CommandFlags flags = CommandFlags.None) {
|
||||
ADBOpera(db.HyperLogLogMerge, destination, first, second, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="sourceKeys"></param>
|
||||
/// <param name="flags"></param>
|
||||
public void HyperLogLogMerge(RedisKey destination, RedisKey[] sourceKeys, CommandFlags flags = CommandFlags.None) {
|
||||
ADBOpera(db.HyperLogLogMerge, destination, sourceKeys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public EndPoint IdentifyEndpoint(RedisKey key = default(RedisKey), CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.IdentifyEndpoint, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool KeyDelete(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyDelete, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long KeyDelete(RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyDelete, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public byte[] KeyDump(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyDump, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool KeyExists(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyExists, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool KeyExpire(RedisKey key, TimeSpan? expiry, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyExpire, key, expiry, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool KeyExpire(RedisKey key, DateTime? expiry, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyExpire, key, expiry, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="database"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool KeyMove(RedisKey key, int database, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyMove, key, database, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool KeyPersist(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyPersist, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisKey KeyRandom(CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyRandom, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="newKey"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool KeyRename(RedisKey key, RedisKey newKey, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyRename, key, newKey, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <param name="flags"></param>
|
||||
public void KeyRestore(RedisKey key, byte[] value, TimeSpan? expiry = null, CommandFlags flags = CommandFlags.None) {
|
||||
ADBOpera(db.KeyRestore, key, value, expiry, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public TimeSpan? KeyTimeToLive(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyTimeToLive, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisType KeyType(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyType, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取列表中某个位置的元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue ListGetByIndex(RedisKey key, long index, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListGetByIndex, key, index, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在pivot的后面插入一个元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pivot"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>插入成功返回列表总长度 插入失败返回-1</returns>
|
||||
public long ListInsertAfter(RedisKey key, RedisValue pivot, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListInsertAfter, key, pivot, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在pivot的前面插入一个元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pivot"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>插入成功返回列表总长度,插入失败返回-1</returns>
|
||||
public long ListInsertBefore(RedisKey key, RedisValue pivot, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListInsertBefore, key, pivot, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从列表的左侧取出一个值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue ListLeftPop(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListLeftPop, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从列表的左侧插入元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long ListLeftPush(RedisKey key, RedisValue value, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListLeftPush, key, value, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从列表的左侧插入一堆值 顺序按数组的顺序插入
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>返回插入后的元素个数</returns>
|
||||
public long ListLeftPush(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListLeftPush, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long ListLength(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListLength, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] ListRange(RedisKey key, long start = 0L, long stop = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListRange, key, start, stop, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从列表中删除某个元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="count">要删除的数量</param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>真正删除的数量</returns>
|
||||
public long ListRemove(RedisKey key, RedisValue value, long count = 0L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListRemove, key, value, count, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从列表的右侧取出一个值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue ListRightPop(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListRightPop, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从source中的右侧取出元素 并把 元素从左侧插入到 destination
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>取出的元素</returns>
|
||||
public RedisValue ListRightPopLeftPush(RedisKey source, RedisKey destination, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListRightPopLeftPush, source, destination, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从列表的右侧插入元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>插入后的元素个数</returns>
|
||||
public long ListRightPush(RedisKey key, RedisValue value, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ListRightPush, key, value, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从列表的右侧插入一堆元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>插入后的元素个数</returns>
|
||||
public long ListRightPush(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None) {
|
||||
|
||||
return FDBOpera(db.ListRightPush, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置列表中某个位置的元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
public void ListSetByIndex(RedisKey key, long index, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
ADBOpera(db.ListSetByIndex, key, index, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 裁剪列表
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="flags"></param>
|
||||
public void ListTrim(RedisKey key, long start, long stop, CommandFlags flags = CommandFlags.None) {
|
||||
ADBOpera(db.ListTrim, key, start, stop, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool LockExtend(RedisKey key, RedisValue value, TimeSpan expiry, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.LockExtend, key, value, expiry, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue LockQuery(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.LockQuery, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool LockRelease(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.LockRelease, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool LockTake(RedisKey key, RedisValue value, TimeSpan expiry, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.LockTake, key, value, expiry, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="channel"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long Publish(RedisChannel channel, RedisValue message, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.Publish, channel, message, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="script"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisResult ScriptEvaluate(string script, RedisKey[] keys = null, RedisValue[] values = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ScriptEvaluate, script, keys, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="hash"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisResult ScriptEvaluate(byte[] hash, RedisKey[] keys = null, RedisValue[] values = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ScriptEvaluate, hash, keys, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="script"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisResult ScriptEvaluate(LuaScript script, object parameters = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ScriptEvaluate, script, parameters, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="script"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisResult ScriptEvaluate(LoadedLuaScript script, object parameters = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.ScriptEvaluate, script, parameters, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 集合添加
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>是否添加成功</returns>
|
||||
public bool SetAdd(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetAdd, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 集合添加
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SetAdd(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetAdd, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合并集合
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] SetCombine(SetOperation operation, RedisKey first, RedisKey second, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetCombine, operation, first, second, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合并集合
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] SetCombine(SetOperation operation, RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetCombine, operation, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合并集合并另存
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SetCombineAndStore(SetOperation operation, RedisKey destination, RedisKey first, RedisKey second, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetCombineAndStore, operation, destination, first, second, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合并集合并另存
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SetCombineAndStore(SetOperation operation, RedisKey destination, RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetCombineAndStore, operation, destination, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否宝航
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool SetContains(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetContains, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 集合元素个数
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SetLength(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetLength, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取集合所有成员
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] SetMembers(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetMembers, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 集合移动到另一个集合
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool SetMove(RedisKey source, RedisKey destination, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetMove, source, destination, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 随机取出一个元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue SetPop(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetPop, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 随机返回一个元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue SetRandomMember(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetRandomMember, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 随机返回count个元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] SetRandomMembers(RedisKey key, long count, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetRandomMembers, key, count, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除一个元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool SetRemove(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetRemove, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除一堆元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SetRemove(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetRemove, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找元素
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pattern"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<RedisValue> SetScan(RedisKey key, RedisValue pattern, int pageSize, CommandFlags flags) {
|
||||
return FDBOpera(db.SetScan, key, pattern, pageSize, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pattern"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="cursor"></param>
|
||||
/// <param name="pageOffset"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<RedisValue> SetScan(RedisKey key, RedisValue pattern = default(RedisValue), int pageSize = 10, long cursor = 0L, int pageOffset = 0, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SetScan, key, pattern, pageSize, cursor, pageOffset, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="sortType"></param>
|
||||
/// <param name="by"></param>
|
||||
/// <param name="get"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] Sort(RedisKey key, long skip = 0L, long take = -1L, Order order = Order.Ascending, SortType sortType = SortType.Numeric, RedisValue by = default(RedisValue), RedisValue[] get = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.Sort, key, skip, take, order, sortType, by, get, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="sortType"></param>
|
||||
/// <param name="by"></param>
|
||||
/// <param name="get"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SortAndStore(RedisKey destination, RedisKey key, long skip = 0L, long take = -1L, Order order = Order.Ascending, SortType sortType = SortType.Numeric, RedisValue by = default(RedisValue), RedisValue[] get = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortAndStore, destination, key, skip, take, order, sortType, by, get, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个元素到有序集合 如果存在则修改其对应的分值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="score"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>是否添加成功</returns>
|
||||
public bool SortedSetAdd(RedisKey key, RedisValue member, double score, CommandFlags flags) {
|
||||
return FDBOpera(db.SortedSetAdd, key, member, score, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="score"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool SortedSetAdd(RedisKey key, RedisValue member, double score, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetAdd, key, member, score, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SortedSetAdd(RedisKey key, SortedSetEntry[] values, CommandFlags flags) {
|
||||
return FDBOpera(db.SortedSetAdd, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SortedSetAdd(RedisKey key, SortedSetEntry[] values, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetAdd, key, values, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="aggregate"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SortedSetCombineAndStore(SetOperation operation, RedisKey destination, RedisKey first, RedisKey second, Aggregate aggregate = Aggregate.Sum, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetCombineAndStore, operation, destination, first, second, aggregate, flags);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="weights"></param>
|
||||
/// <param name="aggregate"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SortedSetCombineAndStore(SetOperation operation, RedisKey destination, RedisKey[] keys, double[] weights = null, Aggregate aggregate = Aggregate.Sum, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetCombineAndStore, operation, destination, keys, weights, aggregate, flags);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public double SortedSetDecrement(RedisKey key, RedisValue member, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetDecrement, key, member, value, flags);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public double SortedSetIncrement(RedisKey key, RedisValue member, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetIncrement, key, member, value, flags);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SortedSetLength(RedisKey key, double min = double.NegativeInfinity, double max = double.PositiveInfinity, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetLength, key, min, max, exclude, flags);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SortedSetLengthByValue(RedisKey key, RedisValue min, RedisValue max, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetLengthByValue, key, min, max, exclude, flags);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] SortedSetRangeByRank(RedisKey key, long start = 0L, long stop = -1L, Order order = Order.Ascending, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetRangeByRank, key, start, stop, order, flags);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public SortedSetEntry[] SortedSetRangeByRankWithScores(RedisKey key, long start = 0L, long stop = -1L, Order order = Order.Ascending, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetRangeByRankWithScores, key, start, stop, order, flags);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] SortedSetRangeByScore(RedisKey key, double start = double.NegativeInfinity, double stop = double.PositiveInfinity, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0L, long take = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetRangeByScore, key, start, stop, exclude, order, skip, take, flags);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public SortedSetEntry[] SortedSetRangeByScoreWithScores(RedisKey key, double start = double.NegativeInfinity, double stop = double.PositiveInfinity, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0L, long take = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetRangeByScoreWithScores, key, start, stop, exclude, order, skip, take, flags);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] SortedSetRangeByValue(RedisKey key, RedisValue min = default(RedisValue), RedisValue max = default(RedisValue), Exclude exclude = Exclude.None, long skip = 0L, long take = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetRangeByValue, key, min, max, exclude, skip, take, flags);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long? SortedSetRank(RedisKey key, RedisValue member, Order order = Order.Ascending, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetRank, key, member, order, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool SortedSetRemove(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetRemove, key, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="members"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SortedSetRemove(RedisKey key, RedisValue[] members, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetRemove, key, members, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SortedSetRemoveRangeByRank(RedisKey key, long start, long stop, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetRemoveRangeByRank, key, start, stop, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SortedSetRemoveRangeByScore(RedisKey key, double start, double stop, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetRemoveRangeByScore, key, start, stop, exclude, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long SortedSetRemoveRangeByValue(RedisKey key, RedisValue min, RedisValue max, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetRemoveRangeByValue, key, min, max, exclude, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pattern"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<SortedSetEntry> SortedSetScan(RedisKey key, RedisValue pattern, int pageSize, CommandFlags flags) {
|
||||
return FDBOpera(db.SortedSetScan, key, pattern, pageSize, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pattern"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="cursor"></param>
|
||||
/// <param name="pageOffset"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<SortedSetEntry> SortedSetScan(RedisKey key, RedisValue pattern = default(RedisValue), int pageSize = 10, long cursor = 0L, int pageOffset = 0, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetScan, key, pattern, pageSize, cursor, pageOffset, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public double? SortedSetScore(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.SortedSetScore, key, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字符串追加
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long StringAppend(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringAppend, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 某范围二进制中出现1的次数
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long StringBitCount(RedisKey key, long start = 0L, long end = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringBitCount, key, start, end, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// first 与 second做位运算,结果放在destination中
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>返回运算后的字符串长度</returns>
|
||||
public long StringBitOperation(Bitwise operation, RedisKey destination, RedisKey first, RedisKey second = default(RedisKey), CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringBitOperation, operation, destination, first, second, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 一堆值做位运算。
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long StringBitOperation(Bitwise operation, RedisKey destination, RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringBitOperation, operation, destination, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取二进制中第一次出现1或0的位置
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="bit"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>返回其位置</returns>
|
||||
public long StringBitPosition(RedisKey key, bool bit, long start = 0L, long end = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringBitPosition, key, bit, start, end, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数值减去一个值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value">减去的值</param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>返回减去后得到的结果</returns>
|
||||
public long StringDecrement(RedisKey key, long value = 1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringDecrement, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数值减去一个值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value">减去的值</param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>返回减去后得到的结果</returns>
|
||||
public double StringDecrement(RedisKey key, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringDecrement, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取String的值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue StringGet(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringGet, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一组String的值
|
||||
/// </summary>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue[] StringGet(RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringGet, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取某位二进制的值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="offset"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>返回原来的值</returns>
|
||||
public bool StringGetBit(RedisKey key, long offset, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringGetBit, key, offset, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取String的一个范围
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue StringGetRange(RedisKey key, long start, long end, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringGetRange, key, start, end, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取原来的String 并用新值替换
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValue StringGetSet(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringGetSet, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取String以及key的过期时间
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public RedisValueWithExpiry StringGetWithExpiry(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringGetWithExpiry, key, flags);
|
||||
}
|
||||
/// <summary>
|
||||
/// 数值增加一个值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long StringIncrement(RedisKey key, long value = 1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringIncrement, key, value, flags);
|
||||
}
|
||||
/// <summary>
|
||||
/// 数值增加一个值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public double StringIncrement(RedisKey key, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringIncrement, key, value, flags);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取字符串长
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public long StringLength(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringLength, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置值字符串
|
||||
/// </summary>
|
||||
/// <param name="key">字符串的键</param>
|
||||
/// <param name="value">字符串的值</param>
|
||||
/// <param name="expiry">过期时间</param>
|
||||
/// <param name="when">那种情况设置值</param>
|
||||
/// <param name="flags">用于操作的标记</param>
|
||||
/// <returns>true 设置成功 false设置失败</returns>
|
||||
/// <remarks>https://redis.io/commands/set</remarks>
|
||||
public bool StringSet(RedisKey key, RedisValue value, TimeSpan? expiry = null, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringSet, key, value, expiry, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置一组字符串值
|
||||
/// </summary>
|
||||
/// <param name="values">字符串键值对</param>
|
||||
/// <param name="when">设置的条件,要么都通过,要么都不通过</param>
|
||||
/// <param name="flags">操作的类型</param>
|
||||
/// <returns>true 表示成功 false表示失败</returns>
|
||||
public bool StringSet(KeyValuePair<RedisKey, RedisValue>[] values, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringSet, values, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置某位二进制的值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="offset"></param>
|
||||
/// <param name="bit"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>返回二进制中原来的值</returns>
|
||||
public bool StringSetBit(RedisKey key, long offset, bool bit, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringSetBit, key, offset, bit, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从偏移量offset 开始 使用 value填充,如果原来没有值或者原来的长度小于 offset ,那从原来的字符串开始到offset使用'\0'字符填充。
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="offset"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns>修改后string的长度</returns>
|
||||
public RedisValue StringSetRange(RedisKey key, long offset, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.StringSetRange, key, offset, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> DebugObjectAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.DebugObjectAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="longitude"></param>
|
||||
/// <param name="latitude"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> GeoAddAsync(RedisKey key, double longitude, double latitude, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.GeoAddAsync, key, longitude, latitude, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> GeoAddAsync(RedisKey key, GeoEntry value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.GeoAddAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> GeoAddAsync(RedisKey key, GeoEntry[] values, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.GeoAddAsync, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> GeoRemoveAsync(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.GeoRemoveAsync, key, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member1"></param>
|
||||
/// <param name="member2"></param>
|
||||
/// <param name="unit"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<double?> GeoDistanceAsync(RedisKey key, RedisValue member1, RedisValue member2, GeoUnit unit = GeoUnit.Meters, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.GeoDistanceAsync, key, member1, member2, unit, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="members"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string[]> GeoHashAsync(RedisKey key, RedisValue[] members, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.GeoHashAsync, key, members, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> GeoHashAsync(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.GeoHashAsync, key, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="members"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<GeoPosition?[]> GeoPositionAsync(RedisKey key, RedisValue[] members, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.GeoPositionAsync, key, members, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<GeoPosition?> GeoPositionAsync(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.GeoPositionAsync, key, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="radius"></param>
|
||||
/// <param name="unit"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<GeoRadiusResult[]> GeoRadiusAsync(RedisKey key, RedisValue member, double radius, GeoUnit unit = GeoUnit.Meters, int count = -1, Order? order = null, GeoRadiusOptions options = GeoRadiusOptions.Default, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.GeoRadiusAsync, key, member, radius, unit, count, order, options, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="longitude"></param>
|
||||
/// <param name="latitude"></param>
|
||||
/// <param name="radius"></param>
|
||||
/// <param name="unit"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<GeoRadiusResult[]> GeoRadiusAsync(RedisKey key, double longitude, double latitude, double radius, GeoUnit unit = GeoUnit.Meters, int count = -1, Order? order = null, GeoRadiusOptions options = GeoRadiusOptions.Default, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.GeoRadiusAsync, key, longitude, latitude, radius, unit, count, order, options, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> HashDecrementAsync(RedisKey key, RedisValue hashField, long value = 1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashDecrementAsync, key, hashField, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<double> HashDecrementAsync(RedisKey key, RedisValue hashField, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashDecrementAsync, key, hashField, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> HashDeleteAsync(RedisKey key, RedisValue hashField, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashDeleteAsync, key, hashField, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashFields"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> HashDeleteAsync(RedisKey key, RedisValue[] hashFields, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashDeleteAsync, key, hashFields, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> HashExistsAsync(RedisKey key, RedisValue hashField, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashExistsAsync, key, hashField, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<HashEntry[]> HashGetAllAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashGetAllAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> HashGetAsync(RedisKey key, RedisValue hashField, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashGetAsync, key, hashField, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashFields"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> HashGetAsync(RedisKey key, RedisValue[] hashFields, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashGetAsync, key, hashFields, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> HashIncrementAsync(RedisKey key, RedisValue hashField, long value = 1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashIncrementAsync, key, hashField, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<double> HashIncrementAsync(RedisKey key, RedisValue hashField, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashIncrementAsync, key, hashField, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> HashKeysAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashKeysAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> HashLengthAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashLengthAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashFields"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task HashSetAsync(RedisKey key, HashEntry[] hashFields, CommandFlags flags = CommandFlags.None) {
|
||||
return ADBOperaAsync(db.HashSetAsync, key, hashFields, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="hashField"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> HashSetAsync(RedisKey key, RedisValue hashField, RedisValue value, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashSetAsync, key, hashField, value, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> HashValuesAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HashValuesAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> HyperLogLogAddAsync(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HyperLogLogAddAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> HyperLogLogAddAsync(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HyperLogLogAddAsync, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> HyperLogLogLengthAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HyperLogLogLengthAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> HyperLogLogLengthAsync(RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.HyperLogLogLengthAsync, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task HyperLogLogMergeAsync(RedisKey destination, RedisKey first, RedisKey second, CommandFlags flags = CommandFlags.None) {
|
||||
return ADBOperaAsync(db.HyperLogLogMergeAsync, destination, first, second, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="sourceKeys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task HyperLogLogMergeAsync(RedisKey destination, RedisKey[] sourceKeys, CommandFlags flags = CommandFlags.None) {
|
||||
return ADBOperaAsync(db.HyperLogLogMergeAsync, destination, sourceKeys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<EndPoint> IdentifyEndpointAsync(RedisKey key = default(RedisKey), CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.IdentifyEndpointAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsConnected(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.IsConnected, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> KeyDeleteAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyDeleteAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> KeyDeleteAsync(RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyDeleteAsync, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<byte[]> KeyDumpAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyDumpAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> KeyExistsAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyExistsAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> KeyExpireAsync(RedisKey key, TimeSpan? expiry, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyExpireAsync, key, expiry, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> KeyExpireAsync(RedisKey key, DateTime? expiry, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyExpireAsync, key, expiry, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="toServer"></param>
|
||||
/// <param name="toDatabase"></param>
|
||||
/// <param name="timeoutMilliseconds"></param>
|
||||
/// <param name="migrateOptions"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task KeyMigrateAsync(RedisKey key, EndPoint toServer, int toDatabase = 0, int timeoutMilliseconds = 0, MigrateOptions migrateOptions = MigrateOptions.None, CommandFlags flags = CommandFlags.None) {
|
||||
return ADBOperaAsync(db.KeyMigrateAsync, key, toServer, toDatabase, timeoutMilliseconds, migrateOptions, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="database"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> KeyMoveAsync(RedisKey key, int database, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyMoveAsync, key, database, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> KeyPersistAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyPersistAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisKey> KeyRandomAsync(CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyRandomAsync, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="newKey"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> KeyRenameAsync(RedisKey key, RedisKey newKey, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyRenameAsync, key, newKey, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task KeyRestoreAsync(RedisKey key, byte[] value, TimeSpan? expiry = null, CommandFlags flags = CommandFlags.None) {
|
||||
return ADBOperaAsync(db.KeyRestoreAsync, key, value, expiry, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<TimeSpan?> KeyTimeToLiveAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyTimeToLiveAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisType> KeyTypeAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.KeyTypeAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> ListGetByIndexAsync(RedisKey key, long index, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListGetByIndexAsync, key, index, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pivot"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> ListInsertAfterAsync(RedisKey key, RedisValue pivot, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListInsertAfterAsync, key, pivot, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="pivot"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> ListInsertBeforeAsync(RedisKey key, RedisValue pivot, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListInsertBeforeAsync, key, pivot, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> ListLeftPopAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListLeftPopAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> ListLeftPushAsync(RedisKey key, RedisValue value, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListLeftPushAsync, key, value, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> ListLeftPushAsync(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListLeftPushAsync, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> ListLengthAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListLengthAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> ListRangeAsync(RedisKey key, long start = 0L, long stop = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListRangeAsync, key, start, stop, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> ListRemoveAsync(RedisKey key, RedisValue value, long count = 0L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListRemoveAsync, key, value, count, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> ListRightPopAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListRightPopAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> ListRightPopLeftPushAsync(RedisKey source, RedisKey destination, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListRightPopLeftPushAsync, source, destination, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> ListRightPushAsync(RedisKey key, RedisValue value, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListRightPushAsync, key, value, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> ListRightPushAsync(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ListRightPushAsync, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task ListSetByIndexAsync(RedisKey key, long index, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return ADBOperaAsync(db.ListSetByIndexAsync, key, index, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task ListTrimAsync(RedisKey key, long start, long stop, CommandFlags flags = CommandFlags.None) {
|
||||
return ADBOperaAsync(db.ListTrimAsync, key, start, stop, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> LockExtendAsync(RedisKey key, RedisValue value, TimeSpan expiry, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.LockExtendAsync, key, value, expiry, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> LockQueryAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.LockQueryAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> LockReleaseAsync(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.LockReleaseAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> LockTakeAsync(RedisKey key, RedisValue value, TimeSpan expiry, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.LockTakeAsync, key, value, expiry, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="channel"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> PublishAsync(RedisChannel channel, RedisValue message, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.PublishAsync, channel, message, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="script"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisResult> ScriptEvaluateAsync(string script, RedisKey[] keys = null, RedisValue[] values = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ScriptEvaluateAsync, script, keys, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="hash"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisResult> ScriptEvaluateAsync(byte[] hash, RedisKey[] keys = null, RedisValue[] values = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ScriptEvaluateAsync, hash, keys, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="script"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisResult> ScriptEvaluateAsync(LuaScript script, object parameters = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ScriptEvaluateAsync, script, parameters, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="script"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisResult> ScriptEvaluateAsync(LoadedLuaScript script, object parameters = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.ScriptEvaluateAsync, script, parameters, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> SetAddAsync(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetAddAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SetAddAsync(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetAddAsync, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SetCombineAndStoreAsync(SetOperation operation, RedisKey destination, RedisKey first, RedisKey second, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetCombineAndStoreAsync, operation, destination, first, second, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SetCombineAndStoreAsync(SetOperation operation, RedisKey destination, RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetCombineAndStoreAsync, operation, destination, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> SetCombineAsync(SetOperation operation, RedisKey first, RedisKey second, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetCombineAsync, operation, first, second, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> SetCombineAsync(SetOperation operation, RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetCombineAsync, operation, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> SetContainsAsync(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetContainsAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SetLengthAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetLengthAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> SetMembersAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetMembersAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> SetMoveAsync(RedisKey source, RedisKey destination, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetMoveAsync, source, destination, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> SetPopAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetPopAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> SetRandomMemberAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetRandomMemberAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="count"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> SetRandomMembersAsync(RedisKey key, long count, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetRandomMembersAsync, key, count, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> SetRemoveAsync(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetRemoveAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SetRemoveAsync(RedisKey key, RedisValue[] values, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SetRemoveAsync, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="sortType"></param>
|
||||
/// <param name="by"></param>
|
||||
/// <param name="get"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SortAndStoreAsync(RedisKey destination, RedisKey key, long skip = 0L, long take = -1L, Order order = Order.Ascending, SortType sortType = SortType.Numeric, RedisValue by = default(RedisValue), RedisValue[] get = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortAndStoreAsync, destination, key, skip, take, order, sortType, by, get, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="sortType"></param>
|
||||
/// <param name="by"></param>
|
||||
/// <param name="get"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> SortAsync(RedisKey key, long skip = 0L, long take = -1L, Order order = Order.Ascending, SortType sortType = SortType.Numeric, RedisValue by = default(RedisValue), RedisValue[] get = null, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortAsync, key, skip, take, order, sortType, by, get, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="score"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> SortedSetAddAsync(RedisKey key, RedisValue member, double score, CommandFlags flags) {
|
||||
return FDBOperaAsync(db.SortedSetAddAsync, key, member, score, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="score"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> SortedSetAddAsync(RedisKey key, RedisValue member, double score, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetAddAsync, key, member, score, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SortedSetAddAsync(RedisKey key, SortedSetEntry[] values, CommandFlags flags) {
|
||||
return FDBOperaAsync(db.SortedSetAddAsync, key, values, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SortedSetAddAsync(RedisKey key, SortedSetEntry[] values, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetAddAsync, key, values, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="aggregate"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SortedSetCombineAndStoreAsync(SetOperation operation, RedisKey destination, RedisKey first, RedisKey second, Aggregate aggregate = Aggregate.Sum, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetCombineAndStoreAsync, operation, destination, first, second, aggregate, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="weights"></param>
|
||||
/// <param name="aggregate"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SortedSetCombineAndStoreAsync(SetOperation operation, RedisKey destination, RedisKey[] keys, double[] weights = null, Aggregate aggregate = Aggregate.Sum, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetCombineAndStoreAsync, operation, destination, keys, weights, aggregate, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<double> SortedSetDecrementAsync(RedisKey key, RedisValue member, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetDecrementAsync, key, member, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<double> SortedSetIncrementAsync(RedisKey key, RedisValue member, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetIncrementAsync, key, member, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SortedSetLengthAsync(RedisKey key, double min = double.NegativeInfinity, double max = double.PositiveInfinity, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetLengthAsync, key, min, max, exclude, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SortedSetLengthByValueAsync(RedisKey key, RedisValue min, RedisValue max, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetLengthByValueAsync, key, min, max, exclude, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> SortedSetRangeByRankAsync(RedisKey key, long start = 0L, long stop = -1L, Order order = Order.Ascending, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetRangeByRankAsync, key, start, stop, order, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<SortedSetEntry[]> SortedSetRangeByRankWithScoresAsync(RedisKey key, long start = 0L, long stop = -1L, Order order = Order.Ascending, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetRangeByRankWithScoresAsync, key, start, stop, order, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> SortedSetRangeByScoreAsync(RedisKey key, double start = double.NegativeInfinity, double stop = double.PositiveInfinity, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0L, long take = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetRangeByScoreAsync, key, start, stop, exclude, order, skip, take, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<SortedSetEntry[]> SortedSetRangeByScoreWithScoresAsync(RedisKey key, double start = double.NegativeInfinity, double stop = double.PositiveInfinity, Exclude exclude = Exclude.None, Order order = Order.Ascending, long skip = 0L, long take = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetRangeByScoreWithScoresAsync, key, start, stop, exclude, order, skip, take, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="skip"></param>
|
||||
/// <param name="take"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> SortedSetRangeByValueAsync(RedisKey key, RedisValue min = default(RedisValue), RedisValue max = default(RedisValue), Exclude exclude = Exclude.None, long skip = 0L, long take = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetRangeByValueAsync, key, min, max, exclude, skip, take, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="order"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long?> SortedSetRankAsync(RedisKey key, RedisValue member, Order order = Order.Ascending, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetRankAsync, key, member, order, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> SortedSetRemoveAsync(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetRemoveAsync, key, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="members"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SortedSetRemoveAsync(RedisKey key, RedisValue[] members, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetRemoveAsync, key, members, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SortedSetRemoveRangeByRankAsync(RedisKey key, long start, long stop, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetRemoveRangeByRankAsync, key, start, stop, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="stop"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SortedSetRemoveRangeByScoreAsync(RedisKey key, double start, double stop, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetRemoveRangeByScoreAsync, key, start, stop, exclude, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
/// <param name="exclude"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> SortedSetRemoveRangeByValueAsync(RedisKey key, RedisValue min, RedisValue max, Exclude exclude = Exclude.None, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetRemoveRangeByValueAsync, key, min, max, exclude, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="member"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<double?> SortedSetScoreAsync(RedisKey key, RedisValue member, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.SortedSetScoreAsync, key, member, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> StringAppendAsync(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringAppendAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> StringBitCountAsync(RedisKey key, long start = 0L, long end = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringBitCountAsync, key, start, end, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="first"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> StringBitOperationAsync(Bitwise operation, RedisKey destination, RedisKey first, RedisKey second = default(RedisKey), CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringBitOperationAsync, operation, destination, first, second, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="operation"></param>
|
||||
/// <param name="destination"></param>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> StringBitOperationAsync(Bitwise operation, RedisKey destination, RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringBitOperationAsync, operation, destination, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="bit"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> StringBitPositionAsync(RedisKey key, bool bit, long start = 0L, long end = -1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringBitPositionAsync, key, bit, start, end, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> StringDecrementAsync(RedisKey key, long value = 1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringDecrementAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<double> StringDecrementAsync(RedisKey key, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringDecrementAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> StringGetAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringGetAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keys"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue[]> StringGetAsync(RedisKey[] keys, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringGetAsync, keys, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="offset"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> StringGetBitAsync(RedisKey key, long offset, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringGetBitAsync, key, offset, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> StringGetRangeAsync(RedisKey key, long start, long end, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringGetRangeAsync, key, start, end, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> StringGetSetAsync(RedisKey key, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringGetSetAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValueWithExpiry> StringGetWithExpiryAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringGetWithExpiryAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> StringIncrementAsync(RedisKey key, long value = 1L, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringIncrementAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<double> StringIncrementAsync(RedisKey key, double value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringIncrementAsync, key, value, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<long> StringLengthAsync(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringLengthAsync, key, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="expiry"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> StringSetAsync(RedisKey key, RedisValue value, TimeSpan? expiry = null, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringSetAsync, key, value, expiry, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="values"></param>
|
||||
/// <param name="when"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> StringSetAsync(KeyValuePair<RedisKey, RedisValue>[] values, When when = When.Always, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringSetAsync, values, when, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="offset"></param>
|
||||
/// <param name="bit"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<bool> StringSetBitAsync(RedisKey key, long offset, bool bit, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringSetBitAsync, key, offset, bit, flags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="offset"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public Task<RedisValue> StringSetRangeAsync(RedisKey key, long offset, RedisValue value, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOperaAsync(db.StringSetRangeAsync, key, offset, value, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
35
GameDAL/db/redis/RedisDataBaseExtensions.cs
Normal file
35
GameDAL/db/redis/RedisDataBaseExtensions.cs
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 由SharpDevelop创建。
|
||||
* 用户: Administrator
|
||||
* 日期: 2018-12-07
|
||||
* 时间: 15:34
|
||||
*
|
||||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
||||
*/
|
||||
using System;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Server.DB.Redis {
|
||||
public partial class IDatabaseProxy {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="flags"></param>
|
||||
/// <returns></returns>
|
||||
public TimeSpan? KeyIdleTime(RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
return FDBOpera(db.KeyIdleTime, key, flags);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class RedisDataBaseExtensions {
|
||||
static readonly RedisValue IDLETIME = "IDLETIME";
|
||||
public static TimeSpan? KeyIdleTime(this IDatabase db, RedisKey key, CommandFlags flags = CommandFlags.None) {
|
||||
var rabbitdb = db as RedisDatabase;
|
||||
var msg = Message.Create(db.Database, flags, RedisCommand.OBJECT, IDLETIME, key);
|
||||
return rabbitdb.ExecuteSync(msg, ResultProcessor.TimeSpanFromSeconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
181
GameDAL/db/redis/RedisDictionary.cs
Normal file
181
GameDAL/db/redis/RedisDictionary.cs
Normal file
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 由SharpDevelop创建。
|
||||
* 用户: Administrator
|
||||
* 日期: 2019-01-02
|
||||
* 时间: 13:07
|
||||
*
|
||||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
||||
*/
|
||||
using System;
|
||||
using Server.Data.Module;
|
||||
using GameData;
|
||||
|
||||
namespace Server.DB.Redis
|
||||
{
|
||||
/// <summary>
|
||||
/// redis字典
|
||||
/// </summary>
|
||||
public static class RedisDictionary
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置所在的redis数据库
|
||||
/// </summary>
|
||||
public const int configDb = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 缓存数据库
|
||||
/// </summary>
|
||||
public const int cachedb = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 版本数据库
|
||||
/// </summary>
|
||||
public const int clientverdb = 2;
|
||||
|
||||
/// <summary>
|
||||
/// 聊天缓存的消息数据
|
||||
/// </summary>
|
||||
public const int chatmessagedb = 3;
|
||||
|
||||
/// <summary>
|
||||
/// 玩家状态存储库
|
||||
/// </summary>
|
||||
public const int PlayerState = 4;
|
||||
|
||||
/// <summary>
|
||||
/// 统计库-6381
|
||||
/// </summary>
|
||||
public const int Statistics = 6;
|
||||
|
||||
/// <summary>
|
||||
/// 游戏服务器细节信息
|
||||
/// </summary>
|
||||
public const string GameSerinfoDetail = "GameSerinfoDetail";
|
||||
|
||||
/// <summary>
|
||||
/// 所有的服务器配置
|
||||
/// </summary>
|
||||
public const string AllServerConfig = "AllServerConfig";
|
||||
|
||||
public const string AllServerConfigVer = "AllServerConfig:ver";
|
||||
|
||||
/// <summary>
|
||||
/// 存储配置服务器用的Key todo 这个key废弃了 1 号库
|
||||
/// </summary>
|
||||
public const string GameConfigServerLuBanKey = "GameConfigServerLuBan";
|
||||
|
||||
/// <summary>
|
||||
/// 玩家活动数据
|
||||
/// </summary>
|
||||
public const string ActivityPlayerData = "Game:ActivityPlayerData:{0}";
|
||||
|
||||
#region 模块数据表
|
||||
|
||||
/// <summary>
|
||||
/// 权重
|
||||
/// </summary>
|
||||
public const string weightsField = "Weights";
|
||||
|
||||
/// <summary>
|
||||
/// 是否死亡
|
||||
/// </summary>
|
||||
public const string dieField = "isDie";
|
||||
|
||||
/// <summary>
|
||||
/// 模块数据表
|
||||
/// </summary>
|
||||
public const string tbModuleData = "tbModuleData";
|
||||
|
||||
/// <summary>
|
||||
/// 节点名称
|
||||
/// </summary>
|
||||
public const string moduleNames = "nodenames";
|
||||
|
||||
#endregion
|
||||
|
||||
#region ModuleOnlineTab
|
||||
|
||||
/// <summary>
|
||||
/// 在线模块编号表
|
||||
/// </summary>
|
||||
public const string tbModuleNum = "tbModuleNum";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="util"></param>
|
||||
/// <returns></returns>
|
||||
public static string dbModuleNumKey(ModuleUtile util){
|
||||
return tbModuleData + "." + util.id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="ModuleUtileId"></param>
|
||||
/// <returns></returns>
|
||||
public static string dbModuleNumKey(int ModuleUtileId){
|
||||
return tbModuleData + "." + ModuleUtileId;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 模块名称表
|
||||
/// </summary>
|
||||
public const string tbModuleName = "Game:tbModuleName";
|
||||
|
||||
/// <summary>
|
||||
/// 游戏信息表名 存储gameid gamesty
|
||||
/// </summary>
|
||||
public const string GameInfoTabName = "Game:NodeInfo:GamesInfo";
|
||||
|
||||
|
||||
#region friendRoom
|
||||
/// <summary>
|
||||
/// 上次创建房间的时间 数据类型hash key1 lastCreateRoomTime 上次的创建时间 key2 lastRoomNum 上次的房间号
|
||||
/// </summary>
|
||||
public const string lastRoomNum = "Game:FriendRoom:lastRoomNum";
|
||||
|
||||
/// <summary>
|
||||
/// 上次创建房间的时间
|
||||
/// </summary>
|
||||
public const string lastCreatRoomTime = "Game:FriendRoom:lastDateTime";
|
||||
|
||||
/// <summary>
|
||||
/// 上次创建房间的房间号
|
||||
/// </summary>
|
||||
public const string lastCreateRoomNum = "Game:FriendRoom:lastRoomNum";
|
||||
|
||||
/// <summary>
|
||||
/// 房间号标记 数据类型 string key=roomTag+"roomNum"; 存储的房间唯一码
|
||||
/// </summary>
|
||||
public const string roomTag = "Game:FriendRoom:Room.";
|
||||
|
||||
/// <summary>
|
||||
/// 玩家的房间号以及唯一码信息
|
||||
/// </summary>
|
||||
public const string PlayerRoomNum = "Game:FriendRoom:Player:";
|
||||
|
||||
/// <summary>
|
||||
/// 房间其他字段
|
||||
/// key1 friendRoomField+"唯一吗" hash 房间详细数据
|
||||
/// key3 friendRoomField+"唯一吗."+"每局详情_idx" hash 存储每局分数
|
||||
/// </summary>
|
||||
public const string friendRoomField = "Game:FriendRoom:weiyima:";
|
||||
|
||||
/// <summary>
|
||||
/// 朋友房战斗数据_用来恢复用的
|
||||
/// </summary>
|
||||
public const string friendRoomfightdata = "Game:FriendRoom:data:";
|
||||
|
||||
/// <summary>
|
||||
/// 朋友房战斗记_用来回放用的
|
||||
/// </summary>
|
||||
public const string friendRoomfightRecord = "Game:FriendRoom:Record:";
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
6
GameDAL/db/redis/RedisTable.txt
Normal file
6
GameDAL/db/redis/RedisTable.txt
Normal file
@ -0,0 +1,6 @@
|
||||
1.客户端版本对应的服务器版本表: ClientVer.[ClientVer] style: Hash
|
||||
2.模块的数据表: tbModuleData.[ver].[id].[num] style: Hash
|
||||
3.模块的名称表: tbModuleName style Hash
|
||||
4.某类模块的在线版本表: tbModuleNum.[id] style:List
|
||||
5.某类某版本模块的在线模块编号表: tbModuleNum.[id].[ver] style:List
|
||||
6.玩家数据表: OnlinePlayers.[id] style:Hash;
|
||||
453
GameDAL/db/redis/redisManager.cs
Normal file
453
GameDAL/db/redis/redisManager.cs
Normal file
@ -0,0 +1,453 @@
|
||||
/*
|
||||
* 由SharpDevelop创建。
|
||||
* 用户: Administrator
|
||||
* 日期: 2018-09-14
|
||||
* 时间: 15:16
|
||||
*
|
||||
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
|
||||
*/
|
||||
|
||||
using System;
|
||||
using StackExchange.Redis;
|
||||
using System.Collections.Generic;
|
||||
using MrWu.Debug;
|
||||
using System.Linq;
|
||||
using GameData;
|
||||
using Server.Config;
|
||||
|
||||
namespace Server.DB.Redis
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库类型
|
||||
/// </summary>
|
||||
public enum DbStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// 主库
|
||||
/// </summary>
|
||||
main,
|
||||
|
||||
/// <summary>
|
||||
/// 比赛
|
||||
/// </summary>
|
||||
bisai
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// redis数据库管理
|
||||
/// </summary>
|
||||
public class redisManager
|
||||
{
|
||||
/* redis 命令大全
|
||||
* del key 删除键
|
||||
* dump key 序列化key 返回序列化的值
|
||||
* exists key 检查key是否存在
|
||||
* exipire key seconds 设置过期的时间
|
||||
* pexipire key milliseconds 设置过期时间毫秒
|
||||
* keys keyspattem 查找给定格式的key
|
||||
* move key db 将key移动到给定数据库db中
|
||||
* persist key 移除key的过期时间
|
||||
* pttl key 返回剩余过期时间以毫秒计
|
||||
* ttl key 返回剩余的过期时间以秒计
|
||||
* randomkey 随机返回一个key
|
||||
* rename key newkey 修改key的名称
|
||||
* renamenx key newkey 仅当newkey不存在时,将key改名为newkey
|
||||
* type key 返回key所存储的值类型
|
||||
*
|
||||
* 字符串类型的命令
|
||||
* set key value 设置key 字符串值
|
||||
* get key 获取key的字符串值
|
||||
* getrange key start end 获取key的字符串一段值
|
||||
* getset key value 从新设置key的值 并返回原来的值
|
||||
* getbit key offset ------
|
||||
* strlen key 返回key存储的字符串长度
|
||||
* mset key1 value1 key2 value2 设置一个或多个字符串的值
|
||||
* msetnx key1 value1 key2 value2 设置一个活多个字符串的值不如果存在key则不设置
|
||||
* setex key seconds value 将值value关联到key,并将key的过期时间设为seconds秒
|
||||
* psetex key millseconds value 将value关联到key,并将key的过期时间设为milliseconds毫秒
|
||||
* incr key 将key中存储的数字值增一 只能value是整数才能使用 并返回存储后的值
|
||||
* incrby key increment 将key中存储的数字值增加increment 并返回存储后的值
|
||||
* incrbyfloat key increment 将key中存储的数字值增加increment的浮点值 并返回存储后的值 存在误差
|
||||
* decr key 将key中存储的数字减一 只有value是数字型的时候才能使用 并返回存储后的值
|
||||
* decrby key decrement 将key中存储的数字值减少decrement 并返回存储后的值
|
||||
* append key value 如果key已经存在并且是一个字符串 append 命令将指定的value追加到key原来的值的末尾 并返回追加后的字符串长度
|
||||
*
|
||||
* hash类型的命令
|
||||
* hmset key hashkey1 value1 hashkey2 vlaue2 将新的hash字段插入到hash表中
|
||||
* hget key hashkey 获取hash中的key
|
||||
* hdel key hashkey1 hashkey2 删除一个或多个hash字段
|
||||
* hexists key filed 查询哈希表中是否存在filed
|
||||
* hgetall key 获取在哈希表中指定的key的所有字段和值
|
||||
* hincrby key field increment 为哈希表中key 的值增加1
|
||||
* hincrbyfloat key field increment 为哈希表中key 的值浮点值增量
|
||||
* hkeys key 获取所有的哈希表中key值
|
||||
* hlen key 获取哈希表中字段的数量
|
||||
* hmget key field1 field2 获取给定字段的值
|
||||
* hset key field vlaue 如果hash表中存在key则 修改key的值 如果不存在则添加
|
||||
* hsernx key filed value 只有在hash表中不存在field字段时才设置值
|
||||
* hvals key 获取hash表中的所有值
|
||||
*
|
||||
* List 列表类型命令
|
||||
* lpush key value1 value2 将值插入到key列表中的头部
|
||||
* blpop key key1 timeout 优先取key中的值如果key中有值返回第一个值 如果key中没有值取key1中的值 如果key1也没有值 则会等待timeout后超时
|
||||
* brpop key key1 timeout 获取最后一个值
|
||||
* brpoplpush source destination timeout 从source 中取出一个值并插入到destination 中 如果没有值知道timeout才停止
|
||||
* lindex key index 通过索引获取表中的元素
|
||||
* linsert key before value
|
||||
* lpop key 移出并获取列表中的第一个元素
|
||||
* lpush key value1 value2 将值插入到已存在key列表中的头部
|
||||
* lpushx key value 将一个值插入到已存在key表中的头部
|
||||
* lrange key start end 获取列表中指定范围的内的元素
|
||||
* lrem key count value count>0表示从头向尾搜索,移除value相等的元素 数量为count count<0表示从尾巴向头搜索,移除value相等的元素 数量为count的绝对值 count = 0 时移除列表中所有的value相等的元素
|
||||
* lset key index value 设置列表index上的值
|
||||
* ltrim key satrt stop 指定列表保留的元素区间,不在区间内的元素将会被删除
|
||||
* rpop key 移除并获取列表中的最后一个元素\
|
||||
* rpoplpush source destination 移除source中的最后一个元素并将该元素添加到destination表中
|
||||
* rpush key value1 value2 将值插入到列表的尾部
|
||||
* rpushx key value 向已存在的表中添加值
|
||||
*
|
||||
* Set 集合命令
|
||||
* sadd key menber1 menber2 向集合中添加一个或多个成员
|
||||
* scard key 获取集合中的成员数量
|
||||
* sdiff key key1 返回所有集合的差集
|
||||
* sdiffstore destination key key1 返回给定所有集合的差集 并存储到destination 中
|
||||
* sinter key key1 缩回所有集合的交集
|
||||
* sindterstore destination key key1 返回所有集合的交集 并存储到destination中
|
||||
* sismember key member 判断member元素是否是集合key的成员
|
||||
* smemers key 返回集合中的所有成员
|
||||
* smove source destination member 将member元素从source集合移动到destination集合中
|
||||
* spop key 移除并返回集合中的一个随机元素
|
||||
* srandmember key count 返回集合中的一个或多个随机元素
|
||||
* serm key member member1 移除集合中的一个或多个成员
|
||||
* sunion key key1 返回所有给定集合的并集
|
||||
* sunionstore destination key1 key2 返回所有给定集合的并集并存储在destination集合中
|
||||
* 迭代集合中的元素xxxx
|
||||
*
|
||||
* 有序集合
|
||||
* zadd key score member1 socre1 member2 向有序集合添加一个或多个成员,或者更新已存在的成员的分数
|
||||
* zcard key 获取有序集合的成员数量
|
||||
* zcount key min max 计算在有序集合中指定区间分数的成员数
|
||||
* zincrby key increment member 有序集合中对指定成员的分数加增量increment
|
||||
* ---zinterstore destination numkeys key key1
|
||||
* --zlexcount key min max 在有序集合中计算指定字典区间内成员数量
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* */
|
||||
|
||||
|
||||
/**
|
||||
* 通配符 * 表示任意一个或多个字符
|
||||
* ? 表示任意字符
|
||||
* [abc] 表示方括号中任意一个字母
|
||||
*
|
||||
* */
|
||||
private redisManager()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主redis 数据库连接
|
||||
/// </summary>
|
||||
private static RedisConnectionHelp mainDBConnection;
|
||||
|
||||
/// <summary>
|
||||
/// 比赛redis 数据库连接
|
||||
/// </summary>
|
||||
private static RedisConnectionHelp bisaiDBConnection;
|
||||
|
||||
private static volatile bool isStart = false;
|
||||
|
||||
/// <summary>
|
||||
/// redis操作数据库代理_逻辑数据库处理
|
||||
/// </summary>
|
||||
public static IDatabaseProxy db
|
||||
{
|
||||
get
|
||||
{
|
||||
if (isStart)
|
||||
{
|
||||
return new IDatabaseProxy(mainDBConnection.Instance.GetDatabase());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// redis 操作数据库代理_逻辑数据库处理
|
||||
/// </summary>
|
||||
/// <param name="idx"></param>
|
||||
/// <returns></returns>
|
||||
public static IDatabaseProxy Getdb(int idx)
|
||||
{
|
||||
if (isStart)
|
||||
return new IDatabaseProxy(mainDBConnection.Instance.GetDatabase(idx));
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取比赛数据库处理
|
||||
/// </summary>
|
||||
/// <param name="idx"></param>
|
||||
/// <returns></returns>
|
||||
public static IDatabaseProxy GetBiSaidb(int idx = -1)
|
||||
{
|
||||
if (isStart)
|
||||
return new IDatabaseProxy(bisaiDBConnection.Instance.GetDatabase(idx));
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据库操作
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IDatabase GetDataBase(DbStyle sty = DbStyle.main, int idx = -1)
|
||||
{
|
||||
ConnectionMultiplexer cm = null;
|
||||
switch (sty)
|
||||
{
|
||||
case DbStyle.main:
|
||||
cm = mainDBConnection.Instance;
|
||||
break;
|
||||
case DbStyle.bisai:
|
||||
cm = bisaiDBConnection.Instance;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cm == null)
|
||||
return null;
|
||||
return cm.GetDatabase(idx);
|
||||
}
|
||||
|
||||
public static List<RedisKey> Keys(string pattern, int dbidx, int pageSize = 1000, DbStyle sty = DbStyle.main)
|
||||
{
|
||||
if (!isStart) return null;
|
||||
|
||||
ConnectionMultiplexer cm = null;
|
||||
switch (sty)
|
||||
{
|
||||
case DbStyle.main:
|
||||
cm = mainDBConnection.Instance;
|
||||
break;
|
||||
case DbStyle.bisai:
|
||||
cm = bisaiDBConnection.Instance;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cm == null)
|
||||
return null;
|
||||
|
||||
List<RedisKey> allkeys = new List<RedisKey>();
|
||||
|
||||
try
|
||||
{
|
||||
var points = cm.GetEndPoints();
|
||||
if (points.Length < 1)
|
||||
{
|
||||
Debug.Error("redis 没有任何连接!");
|
||||
return null;
|
||||
}
|
||||
|
||||
IServer server = cm.GetServer(points[0]);
|
||||
|
||||
if (points.Length > 1)
|
||||
{
|
||||
ClusterConfiguration clusternodes = server.ClusterNodes();
|
||||
foreach (var item in clusternodes.Nodes)
|
||||
{
|
||||
if (!item.IsSlave)
|
||||
{
|
||||
IServer temp = cm.GetServer(item.EndPoint);
|
||||
IEnumerable<RedisKey> rks = temp.Keys(dbidx, pattern,pageSize);
|
||||
foreach (RedisKey rk in rks)
|
||||
{
|
||||
allkeys.Add(rk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var rks = server.Keys(dbidx, pattern, pageSize);
|
||||
|
||||
foreach (var key in rks)
|
||||
{
|
||||
allkeys.Add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Error("查询错误asdsahdjk" + e.ToString());
|
||||
return allkeys;
|
||||
}
|
||||
|
||||
|
||||
return allkeys;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动redis 服务器
|
||||
/// </summary>
|
||||
/// <param name="AllowAdmin">管理员模式</param>
|
||||
public static void Start(bool AllowAdmin = false)
|
||||
{
|
||||
for (int i = 0; i < RedisConfigCategory.Instance.DataList.Count; i++)
|
||||
{
|
||||
var item = RedisConfigCategory.Instance.DataList[i];
|
||||
switch (item.Name)
|
||||
{
|
||||
case "main":
|
||||
mainDBConnection = new RedisConnectionHelp();
|
||||
mainDBConnection.Start(item, AllowAdmin);
|
||||
break;
|
||||
case "bisai":
|
||||
bisaiDBConnection = new RedisConnectionHelp();
|
||||
bisaiDBConnection.Start(item, AllowAdmin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
isStart = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ConnectionMultiplexer对象管理帮助类__单例换多例
|
||||
/// </summary>
|
||||
public class RedisConnectionHelp
|
||||
{
|
||||
private readonly object Locker = new object();
|
||||
private ConnectionMultiplexer _instance;
|
||||
|
||||
/// <summary>
|
||||
/// 单例获取
|
||||
/// </summary>
|
||||
public ConnectionMultiplexer Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
lock (Locker)
|
||||
{
|
||||
if (_instance == null || !_instance.IsConnected)
|
||||
{
|
||||
//Debug.Error("获取新的实例!!!!");
|
||||
_instance = GetManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
RedisConfig redisConfig;
|
||||
bool AllowAdmin;
|
||||
|
||||
/// <summary>
|
||||
/// 启动redis
|
||||
/// </summary>
|
||||
/// <param name="redisConfig_"></param>
|
||||
/// <param name="AllowAdmin_"></param>
|
||||
public void Start(RedisConfig redisConfig_, bool AllowAdmin_ = false)
|
||||
{
|
||||
redisConfig = redisConfig_;
|
||||
AllowAdmin = AllowAdmin_;
|
||||
}
|
||||
|
||||
private ConnectionMultiplexer GetManager(string connectionString = null)
|
||||
{
|
||||
ConfigurationOptions options = new ConfigurationOptions();
|
||||
|
||||
options.ConnectTimeout = redisConfig.ConnectTimeOut;
|
||||
options.AllowAdmin = AllowAdmin;
|
||||
options.AbortOnConnectFail = false; //true 表示连接失败将不会创建链接实例
|
||||
options.ConnectRetry = 5; //失败尝试重新链接的次数
|
||||
|
||||
options.EndPoints.Add(redisConfig.Host, redisConfig.Port);
|
||||
|
||||
ConnectionMultiplexer cml = ConnectionMultiplexer.Connect(options);
|
||||
|
||||
//redisPool.TimeoutMilliseconds = 3000;
|
||||
|
||||
cml.ConnectionFailed += MuxerConnectionFailed;
|
||||
cml.ConnectionRestored += MuxerConnectionRestored;
|
||||
cml.ErrorMessage += MuxerErrorMessage;
|
||||
cml.ConfigurationChanged += MuxerConfigurationChanged;
|
||||
cml.HashSlotMoved += MuxerHashSlotMoved;
|
||||
cml.InternalError += MuxerInternalError;
|
||||
|
||||
return cml;
|
||||
}
|
||||
|
||||
#region 事件
|
||||
|
||||
/// <summary>
|
||||
/// 配置更改时
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MuxerConfigurationChanged(object sender, EndPointEventArgs e)
|
||||
{
|
||||
Debug.Fatal("Configuration changed: " + e.EndPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发生错误时
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MuxerErrorMessage(object sender, RedisErrorEventArgs e)
|
||||
{
|
||||
Debug.Fatal("ErrorMessage: " + e.Message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重新建立连接之前的错误
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MuxerConnectionRestored(object sender, ConnectionFailedEventArgs e)
|
||||
{
|
||||
Debug.Fatal("ConnectionRestored: " + e.EndPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 连接失败 , 如果重新连接成功你将不会收到这个通知
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MuxerConnectionFailed(object sender, ConnectionFailedEventArgs e)
|
||||
{
|
||||
Debug.Fatal("重新连接:Endpoint failed: " + e.EndPoint + ", " + e.FailureType +
|
||||
(e.Exception == null ? "" : (", " + e.Exception.Message)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更改集群
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MuxerHashSlotMoved(object sender, HashSlotMovedEventArgs e)
|
||||
{
|
||||
Debug.Fatal("HashSlotMoved:NewEndPoint" + e.NewEndPoint + ", OldEndPoint" + e.OldEndPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// redis类库错误
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MuxerInternalError(object sender, InternalErrorEventArgs e)
|
||||
{
|
||||
Debug.Fatal("InternalError:Message" + e.Exception.Message);
|
||||
}
|
||||
|
||||
#endregion 事件
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user