Example #1
0
 /// <summary>
 /// Removes the entry for the specified key only if it is currently
 /// mapped to the specified value.
 /// </summary>
 /// <param name="invocable">
 /// The interface it extends.
 /// </param>
 /// <param name="key">
 /// Key with which the specified value is associated.
 /// </param>
 /// <param name="value">
 /// Value expected to be associated with the specified key.
 /// </param>
 /// <returns>
 /// True if the value was removed.
 /// </returns>
 public static object Remove(this IInvocableCache invocable, object key, object value)
 {
     return(invocable.Invoke(key, CacheProcessors.Remove(value)));
 }
Example #2
0
 /// <summary>
 /// Returns the value to which the specified key is mapped, or
 /// the defaultValue if this cache contains no mapping for the key.
 /// </summary>
 /// <param name="invocable">
 /// The interface it extends.
 /// </param>
 /// <param name="key">
 /// The key whose associated value is to be returned.
 /// </param>
 /// <param name="defaultValue">
 /// The default value of the key.
 /// </param>
 /// <returns>
 /// The value to which the specified key is mapped, or defaultValue
 /// if this cache contains no mapping for the key.
 /// </returns>
 public static object GetOrDefault(this IInvocableCache invocable, object key, object defaultValue)
 {
     return(((Optional)invocable.Invoke(key, CacheProcessors.GetOrDefault())).OrElse(defaultValue));
 }
Example #3
0
 /// <summary>
 /// If the specified key is not already associated with a value
 /// (or is mapped to null) associates it with the given value and
 /// returns null, else returns the current value.
 /// </summary>
 /// <param name="invocable">
 /// The interface it extends.
 /// </param>
 /// <param name="key">
 /// Key with which the specified value is to be associated.
 /// </param>
 /// <param name="value">
 /// Value to be associated with the specified key.
 /// </param>
 /// <returns>
 /// The current value associated with the specified key, or
 /// null if there was no mapping for the key.
 /// </returns>
 public static object InsertIfAbsent(this IInvocableCache invocable, object key, object value)
 {
     return(invocable.Invoke(key, CacheProcessors.InsertIfAbsent(value)));
 }
Example #4
0
 /// <summary>
 /// Replaces the entry for the specified key only if currently
 /// mapped to the specified value.
 /// </summary>
 /// <param name="invocable">
 /// The interface it extends.
 /// </param>
 /// <param name="key">
 /// Key with which the specified value is associated.
 /// </param>
 /// <param name="oldValue">
 /// Value expected to be associated with the specified key.
 /// </param>
 /// <param name="newValue">
 /// Value to be associated with the specified key.
 /// </param>
 /// <returns>
 /// True if the value was replaced.
 /// </returns>
 public static object Replace(this IInvocableCache invocable, object key, object oldValue, object newValue)
 {
     return(invocable.Invoke(key, CacheProcessors.Replace(oldValue, newValue)));
 }