You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

54 lines
1.3 KiB

using ServiceStack.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OT.RedisServer
{
/// <summary>
/// RedisOperatorBase类,是redis操作的基类,继承自IDisposable接口,主要用于释放内存
/// </summary>
public abstract class RedisOperatorBase : IDisposable
{
protected IRedisClient Redis { get; private set; }
private bool _disposed = false;
protected RedisOperatorBase()
{
Redis = RedisManager.GetClient();
}
protected virtual void Dispose(bool disposing)
{
if (!this._disposed)
{
if (disposing)
{
Redis.Dispose();
Redis = null;
}
}
this._disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// 保存数据DB文件到硬盘
/// </summary>
public void Save()
{
Redis.Save();
}
/// <summary>
/// 异步保存数据DB文件到硬盘
/// </summary>
public void SaveAsync()
{
Redis.SaveAsync();
}
}
}