/*
 * 由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);
        }
    }    
}