protected bool SetInternal(string key, object value, TimeSpan expireTime, bool async = false) { bool result = false; var data = (RedisValue)StateBinarySerializer.Serialize(value); var redisDatabase = GetRedisDatabase(); if (async) { redisDatabase.StringSetAsync(key, data, expireTime); } else { result = redisDatabase.StringSet(key, data, expireTime); } return(result); }
protected object GetInternal(string key, bool slide = true, bool slideAsync = true, bool preferSlave = true) { var redisDatabase = GetRedisDatabase(); var flag = CommandFlags.None; if (preferSlave) { flag = CommandFlags.PreferSlave; } var data = redisDatabase.StringGet(key, flag); var result = StateBinarySerializer.Deserialize(data); if (slide) { var expire = UnlockedExtensions.GetNextTimeout(configuration.SessionTimeout); var prefix = GetSessionItemPrefix(); SlideInternal(prefix, expire, slideAsync); } return(result); }