/// <summary> /// Sets a string in the specified cache with the specified key. /// </summary> /// <param name="cache">The cache in which to store the data.</param> /// <param name="key">The key to store the data in.</param> /// <param name="value">The data to store in the cache.</param> /// <param name="options">The cache options for the entry.</param> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="key"/> or <paramref name="value"/> is null.</exception> public static void SetString(this LucidCache cache, string key, string value, DistributedCacheEntryOptions options) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } cache.Set(key, Encoding.UTF8.GetBytes(value), options); }
/// <summary> /// Sets a sequence of bytes in the specified cache with the specified key. /// </summary> /// <param name="cache">The cache in which to store the data.</param> /// <param name="key">The key to store the data in.</param> /// <param name="value">The data to store in the cache.</param> /// <exception cref="System.ArgumentNullException">Thrown when <paramref name="key"/> or <paramref name="value"/> is null.</exception> public static void Set(this LucidCache cache, string key, byte[] value) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } cache.Set(key, value, new DistributedCacheEntryOptions()); }