/// <summary> /// Asynchronously set keyType to hold the string value. If keyType already holds a value, it is overwritten, regardless of its type. /// </summary> /// <param name="keyType">RedisDBKey value to convert to string and lookup.</param> /// <param name="obj">MsgPack object to serialize.</param> /// <param name="expiry">(optional) TimeSpan date to expire value at.</param> /// <param name="when">Allows you to specify criteria for setting object. Update only if not-exist, etc.</param> /// <param name="commandFlags">Flags to pass to Redis.</param> /// <returns>True or false depending on if value was successfully set.</returns> public async Task <bool> SetValueAsync( RedisDBKeyTypes keyType, MessagePackSerializableObject obj, TimeSpan?expiry = null, SetWhen when = SetWhen.Always, RedisCommandFlags commandFlags = RedisCommandFlags.None) { return(await SetValueAsync(keyType, "", obj, expiry, when, commandFlags)); }
/// <summary> /// Asynchronously set keyType to hold the string value. If keyType already holds a value, it is overwritten, regardless of its type. /// </summary> /// <param name="keyType">Redis keyType to set.</param> /// <param name="keyIdentifier">suffix added to keyType for unique keys. If unused, set to ""</param> /// <param name="data">String to insert for data.</param> /// <param name="expiry">(optional) TimeSpan date to expire value at.</param> /// <param name="when">Allows you to specify criteria for setting object. Update only if not-exist, etc.</param> /// <param name="commandFlags">Flags to pass to Redis.</param> /// <returns>True or false depending on if value was successfully set.</returns> public Task <bool> SetRawValueAsync( RedisDBKeyTypes keyType, string keyIdentifier, string data, TimeSpan?expiry = null, SetWhen when = SetWhen.Always, RedisCommandFlags commandFlags = RedisCommandFlags.None) { string keyString = keyType + "_" + keyIdentifier; #if DEBUG LogDebug("[Redis Async Set Raw]: {0}" + expiry, keyString, data.ToString()); #endif return(_db.StringSetAsync(keyString, data, expiry, (When)when, (CommandFlags)commandFlags)); }
/// <summary> /// Asynchronously set keyType to hold the string value. If keyType already holds a value, it is overwritten, regardless of its type. /// </summary> /// <param name="keyType">Redis keyType to set.</param> /// <param name="keyIdentifier">suffix added to keyType for unique keys. If unused, set to ""</param> /// <param name="obj">MsgPack object to serialize.</param> /// <param name="expiry">(optional) TimeSpan date to expire value at.</param> /// <param name="when">Allows you to specify criteria for setting object. Update only if not-exist, etc.</param> /// <param name="commandFlags">Flags to pass to Redis.</param> /// <returns>True or false depending on if value was successfully set.</returns> public Task <bool> SetValueAsync( RedisDBKeyTypes keyType, string keyIdentifier, MessagePackSerializableObject obj, TimeSpan?expiry = null, SetWhen when = SetWhen.Always, RedisCommandFlags commandFlags = RedisCommandFlags.None) { string keyString = keyType + "_" + keyIdentifier; #if DEBUG LogDebug("[Redis Async Set]: {0}" + expiry, keyString, obj.Serialize().ToString()); #endif return(_db.StringSetAsync(keyString, obj.Serialize(), expiry, (When)when, (CommandFlags)commandFlags)); }