/// <summary> /// Sets to database. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="value">The value.</param> /// <param name="key">The key.</param> /// <param name="databaseNumber">The database number.</param> /// <param name="ttl">The TTL.</param> /// <param name="fireAndForget">if set to <c>true</c> [fire and forget].</param> public void SetToDatabase <T>(T value, string key, int databaseNumber, TimeSpan?ttl = null, bool fireAndForget = false) { var flags = CommandFlags.None; if (fireAndForget) { flags = CommandFlags.FireAndForget; } var inputBytes = _connector.Serializer.Serialize(value); _connector.GetDatabase(databaseNumber).StringSet(key, inputBytes, ttl, When.Always, flags); }
/// <summary> /// Gets the hit. /// </summary> /// <param name="hitName">Name of the hit.</param> /// <returns>System.Int32.</returns> public int GetHit(string hitName) { var result = _redis.GetDatabase(HitDatabase).StringGet(hitName, CommandFlags.PreferReplica); return(result.HasValue ? result.ToString().ToInt32() : 0); }