Example #1
0
 public QueueWorker(IConfiguration config, IVoteData data, ILogger <QueueWorker> logger, IRedisStore redisStore)
 {
     _config     = config;
     _data       = data;
     _logger     = logger;
     _redisStore = redisStore;
 }
Example #2
0
        /// <summary>
        /// 获取随机DB
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static int GetRandomNumber(this IRedisStore redisStore, string key)
        {
            var md5       = Md5(key);
            var n         = md5[0];
            var numString = "0123456789abcdef";

            return(numString.IndexOf(n));
        }
Example #3
0
 public AppRedisCacheStore(
     IMemoryStore memoryStore,
     IRedisStore redisStore,
     IMutilCacheStore mutilCacheStore)
 {
     _memoryStore     = memoryStore;
     _redisStore      = redisStore;
     _mutilCacheStore = mutilCacheStore;
 }
Example #4
0
        /// <summary>
        /// RedisValue[]转List对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="values"></param>
        /// <returns></returns>
        public static List <T> RedisValuesToList <T>(this IRedisStore redisStore, RedisValue[] values)
        {
            List <T> result = new List <T>();

            foreach (var item in values)
            {
                var model = redisStore.RedisValueToObject <T>(item);
                result.Add(model);
            }
            return(result);
        }
Example #5
0
 public void Dispose()
 {
     redisHash      = null;
     redisKey       = null;
     redisList      = null;
     redisLock      = null;
     redisSet       = null;
     redisSortedSet = null;
     redisStore     = null;
     redisString    = null;
     redisSubscribe = null;
 }
Example #6
0
 /// <summary>
 /// RedisValueToObject
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="value"></param>
 /// <returns></returns>
 public static T RedisValueToObject <T>(this IRedisStore redisStore, RedisValue value)
 {
     if (typeof(T).Name.Equals(typeof(string).Name))
     {
         return(JsonConvert.DeserializeObject <T>($"'{value}'"));
     }
     else
     {
         T t = JsonConvert.DeserializeObject <T>(value);
         if (t == null)
         {
             Console.WriteLine($"reids.ConvertObj.t:{null}");
         }
         return(t);
     }
 }
Example #7
0
 public TaskController(ILogger <SiteController> logger,
                       IRedisStore redisStore,
                       ISystemDictionaryRepository systemDictionaryRepository,
                       ITaskInfoRepository taskInfoRepository,
                       ITaskDetailsRepository taskDetailsRepository,
                       IMemberIncomeRepository memberIncomeRepository,
                       ITaskNoviceLogRepository taskNoviceLogRepository,
                       ITaskInfoApp taskInfoApp)
 {
     this._ILogger     = logger;
     this._IRedisStore = redisStore;
     this._ISystemDictionaryRepository = systemDictionaryRepository;
     this._ITaskInfoApp             = taskInfoApp;
     this._ITaskInfoRepository      = taskInfoRepository;
     this._ITaskDetailsRepository   = taskDetailsRepository;
     this._ITaskNoviceLogRepository = taskNoviceLogRepository;
     this._IMemberIncomeRepository  = memberIncomeRepository;
 }
Example #8
0
        public MutilCacheStore(IMemoryStore memoryStore, IRedisStore redisStore)
        {
            _memoryStore = memoryStore;
            _redisStore  = redisStore;

            _subscribeObject = _redisStore.Client.Subscribe((TOPIC_NAME, (msg) =>
            {
                if (msg == null || string.IsNullOrEmpty(msg.Body))
                {
                    return;
                }

                var message = msg.Body.ToObject <CacheMessage>();
                if (message == null)
                {
                    return;
                }

                OnMessage(message);
            }
                                                             ));
        }
Example #9
0
        /// <summary>
        /// 对象转字符串
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string ObjectToString <T>(this IRedisStore redisStore, T value)
        {
            string result = value is string?value.ToString() : JsonConvert.SerializeObject(value);

            return(result);
        }
Example #10
0
        public static T Do <T>(this IRedisStore redisStore, Func <IDatabaseAsync, T> func, int index = 0)
        {
            var database = redisStore.Instance.GetDatabase(index);

            return(func(database));
        }
Example #11
0
 public WebCategoryRedis(IRedisStore redisStore)
 {
     this._IRedisStore = redisStore;
 }
Example #12
0
 public WebNewsRedis(IRedisStore redisStore)
 {
     this._IRedisStore = redisStore;
 }
Example #13
0
 public RedisRepository(IRedisStore redisStore)
 {
     this._IRedisStore = redisStore;
 }
Example #14
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="httpContextAccessor"></param>
 /// <param name="configuration"></param>
 public JwtRedis(IRedisStore redisStore, IHttpContextAccessor httpContextAccessor, IConfiguration configuration)
 {
     _IRedisStore         = redisStore;
     _httpContextAccessor = httpContextAccessor;
     _configuration       = configuration;
 }
Example #15
0
 public RedisPublisher(IRedisStore redisStore)
 {
     _redisStore = redisStore;
 }
Example #16
0
 public RedisClientFactory(IRedisStore redisStore, ILoggerFactory loggerFactory)
 {
     _redisStore    = redisStore;
     _loggerFactory = loggerFactory;
 }
Example #17
0
 public RedisLokiLockHandler(EndPoint[] redisEndPoints)
 {
     _redisStore = RedisStore.Instance.Initialize(redisEndPoints);
     _token      = Environment.MachineName;
 }
Example #18
0
 public WebSiteRedis(IRedisStore redisStore) : base(redisStore)
 {
     this._IRedisStore = redisStore;
 }
Example #19
0
 public RedisSubscriber(IRedisStore redisStore)
 {
     _redisStore = redisStore;
     LogPrefix   = this.GetType().Name;
 }
 public RedisScheduler(IRedisStore redisStore)
 {
     _redisStore = redisStore;
 }
Example #21
0
 public RedisGeneralCache(IRedisStore redisStore)
 {
     _redisStore = redisStore ?? throw new ArgumentNullException(nameof(redisStore));
 }
Example #22
0
 /// <summary>
 /// stringList对象转RedisKey[],多个Keys操作
 /// </summary>
 /// <param name="redisKeys"></param>
 /// <returns></returns>
 public static RedisKey[] StringsToRedisKeys(this IRedisStore redisStore, List <string> redisKeys)
 {
     return(redisKeys.Select(redisKey => (RedisKey)redisKey).ToArray());
 }
Example #23
0
 public WebChannelRedis(IRedisStore redisStore) : base(redisStore)
 {
     this._IRedisStore = redisStore;
 }
Example #24
0
 public RedisLokiLockHandler(EndPoint[] redisEndPoints)
 {
     _redisStore = RedisStore.Instance.Initialize(redisEndPoints);
 }