Skip to main content

CacheClientExtensions

Assembly: ServiceStack.dll
View Source
Declaration
public static class CacheClientExtensions

Methods

Set<T>(ICacheClient, String, T, Nullable<TimeSpan>)

View Source
Declaration
public static void Set<T>(this ICacheClient cache, string cacheKey, T value, TimeSpan? expireCacheIn)
Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
System.StringcacheKey
<T>value
System.Nullable<System.TimeSpan>expireCacheIn
Type Parameters
  • T

SetAsync<T>(ICacheClientAsync, String, T, Nullable<TimeSpan>, CancellationToken)

View Source
Declaration
public static async Task SetAsync<T>(this ICacheClientAsync cache, string cacheKey, T value, TimeSpan? expireCacheIn, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
System.StringcacheKey
<T>value
System.Nullable<System.TimeSpan>expireCacheIn
System.Threading.CancellationTokentoken
Type Parameters
  • T

GetDate(IRequest)

View Source
Declaration
public static DateTime? GetDate(this IRequest req)
Returns

System.Nullable<System.DateTime>

Parameters
TypeName
ServiceStack.Web.IRequestreq

GetIfModifiedSince(IRequest)

View Source
Declaration
public static DateTime? GetIfModifiedSince(this IRequest req)
Returns

System.Nullable<System.DateTime>

Parameters
TypeName
ServiceStack.Web.IRequestreq

HasValidCache(ICacheClient, IRequest, String, Nullable<DateTime>, out Nullable<DateTime>)

View Source
Declaration
public static bool HasValidCache(this ICacheClient cache, IRequest req, string cacheKey, DateTime? checkLastModified, out DateTime? lastModified)
Returns

System.Boolean

Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
ServiceStack.Web.IRequestreq
System.StringcacheKey
System.Nullable<System.DateTime>checkLastModified
System.Nullable<System.DateTime>lastModified

HasValidCacheAsync(ICacheClientAsync, IRequest, String, Nullable<DateTime>, CancellationToken)

View Source
Declaration
public static async Task<CacheClientExtensions.ValidCache> HasValidCacheAsync(this ICacheClientAsync cache, IRequest req, string cacheKey, DateTime? checkLastModified, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<ServiceStack.CacheClientExtensions.ValidCache>

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
ServiceStack.Web.IRequestreq
System.StringcacheKey
System.Nullable<System.DateTime>checkLastModified
System.Threading.CancellationTokentoken

ResolveFromCache(ICacheClient, String, IRequest)

View Source
Declaration
public static object ResolveFromCache(this ICacheClient cache, string cacheKey, IRequest req)
Returns

System.Object

Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
System.StringcacheKey
ServiceStack.Web.IRequestreq

ResolveFromCacheAsync(ICacheClientAsync, String, IRequest, CancellationToken)

View Source
Declaration
public static async Task<object> ResolveFromCacheAsync(this ICacheClientAsync cache, string cacheKey, IRequest req, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<System.Object>

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
System.StringcacheKey
ServiceStack.Web.IRequestreq
System.Threading.CancellationTokentoken

Cache(ICacheClient, String, Object, IRequest, Nullable<TimeSpan>)

View Source
Declaration
public static object Cache(this ICacheClient cache, string cacheKey, object responseDto, IRequest req, TimeSpan? expireCacheIn = null)
Returns

System.Object

Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
System.StringcacheKey
System.ObjectresponseDto
ServiceStack.Web.IRequestreq
System.Nullable<System.TimeSpan>expireCacheIn

CacheAsync(ICacheClientAsync, String, Object, IRequest, Nullable<TimeSpan>, CancellationToken)

View Source
Declaration
public static async Task<object> CacheAsync(this ICacheClientAsync cache, string cacheKey, object responseDto, IRequest req, TimeSpan? expireCacheIn = null, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task<System.Object>

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
System.StringcacheKey
System.ObjectresponseDto
ServiceStack.Web.IRequestreq
System.Nullable<System.TimeSpan>expireCacheIn
System.Threading.CancellationTokentoken

ClearCaches(ICacheClient, String[])

View Source
Declaration
public static void ClearCaches(this ICacheClient cache, params string[] cacheKeys)
Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
System.String[]cacheKeys

ClearCachesAsync(ICacheClientAsync, String[], CancellationToken)

View Source
Declaration
public static async Task ClearCachesAsync(this ICacheClientAsync cache, string[] cacheKeys, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
System.String[]cacheKeys
System.Threading.CancellationTokentoken

GetCacheKeyForSerialized(String, String, String)

View Source
Declaration
public static string GetCacheKeyForSerialized(string cacheKey, string mimeType, string modifiers)
Returns

System.String

Parameters
TypeName
System.StringcacheKey
System.StringmimeType
System.Stringmodifiers

GetCacheKeyForCompressed(String, String)

View Source
Declaration
public static string GetCacheKeyForCompressed(string cacheKeySerialized, string compressionType)
Returns

System.String

Parameters
TypeName
System.StringcacheKeySerialized
System.StringcompressionType

RemoveByPattern(ICacheClient, String)

Removes items from cache that have keys matching the specified wildcard pattern

View Source
Declaration
public static void RemoveByPattern(this ICacheClient cacheClient, string pattern)
Parameters
TypeNameDescription
ServiceStack.Caching.ICacheClientcacheClientCache client

| | System.String | pattern | The wildcard, where "*" means any sequence of characters and "?" means any single character.

|

RemoveByPatternAsync(ICacheClientAsync, String, CancellationToken)

Removes items from cache that have keys matching the specified wildcard pattern

View Source
Declaration
public static Task RemoveByPatternAsync(this ICacheClientAsync cacheClient, string pattern, CancellationToken token = default(CancellationToken))
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
ServiceStack.Caching.ICacheClientAsynccacheClientCache client

| | System.String | pattern | The wildcard, where "*" means any sequence of characters and "?" means any single character.

| | System.Threading.CancellationToken | token |

|

RemoveByRegex(ICacheClient, String)

Removes items from the cache based on the specified regular expression pattern

View Source
Declaration
public static void RemoveByRegex(this ICacheClient cacheClient, string regex)
Parameters
TypeNameDescription
ServiceStack.Caching.ICacheClientcacheClientCache client

| | System.String | regex | Regular expression pattern to search cache keys

|

RemoveByRegexAsync(ICacheClientAsync, String)

Removes items from the cache based on the specified regular expression pattern

View Source
Declaration
public static Task RemoveByRegexAsync(this ICacheClientAsync cacheClient, string regex)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
ServiceStack.Caching.ICacheClientAsynccacheClientCache client

| | System.String | regex | Regular expression pattern to search cache keys

|

GetKeysByPattern(ICacheClient, String)

View Source
Declaration
public static IEnumerable<string> GetKeysByPattern(this ICacheClient cache, string pattern)
Returns

System.Collections.Generic.IEnumerable<System.String>

Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
System.Stringpattern

GetAllKeys(ICacheClient)

View Source
Declaration
public static IEnumerable<string> GetAllKeys(this ICacheClient cache)
Returns

System.Collections.Generic.IEnumerable<System.String>

Parameters
TypeName
ServiceStack.Caching.ICacheClientcache

GetKeysStartingWith(ICacheClient, String)

View Source
Declaration
public static IEnumerable<string> GetKeysStartingWith(this ICacheClient cache, string prefix)
Returns

System.Collections.Generic.IEnumerable<System.String>

Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
System.Stringprefix

GetKeysByPatternAsync(ICacheClientAsync, String)

View Source
Declaration
public static IAsyncEnumerable<string> GetKeysByPatternAsync(this ICacheClientAsync cache, string pattern)
Returns

IAsyncEnumerable<System.String>

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
System.Stringpattern

GetAllKeysAsync(ICacheClientAsync)

View Source
Declaration
public static async IAsyncEnumerable<string> GetAllKeysAsync(this ICacheClientAsync cache)
Returns

IAsyncEnumerable<System.String>

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache

GetKeysStartingWithAsync(ICacheClientAsync, String)

View Source
Declaration
public static async IAsyncEnumerable<string> GetKeysStartingWithAsync(this ICacheClientAsync cache, string prefix)
Returns

IAsyncEnumerable<System.String>

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
System.Stringprefix

GetOrCreate<T>(ICacheClient, String, Func<T>)

View Source
Declaration
public static T GetOrCreate<T>(this ICacheClient cache, string key, Func<T> createFn)
Returns

<T>

Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
System.Stringkey
System.Func<<T>>createFn
Type Parameters
  • T

GetOrCreateAsync<T>(ICacheClientAsync, String, Func<Task<T>>)

View Source
Declaration
public static async Task<T> GetOrCreateAsync<T>(this ICacheClientAsync cache, string key, Func<Task<T>> createFn)
Returns

System.Threading.Tasks.Task<<T>>

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
System.Stringkey
System.Func<System.Threading.Tasks.Task<<T>>>createFn
Type Parameters
  • T

GetOrCreate<T>(ICacheClient, String, TimeSpan, Func<T>)

View Source
Declaration
public static T GetOrCreate<T>(this ICacheClient cache, string key, TimeSpan expiresIn, Func<T> createFn)
Returns

<T>

Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
System.Stringkey
System.TimeSpanexpiresIn
System.Func<<T>>createFn
Type Parameters
  • T

GetOrCreateAsync<T>(ICacheClientAsync, String, TimeSpan, Func<Task<T>>)

View Source
Declaration
public static async Task<T> GetOrCreateAsync<T>(this ICacheClientAsync cache, string key, TimeSpan expiresIn, Func<Task<T>> createFn)
Returns

System.Threading.Tasks.Task<<T>>

Parameters
TypeName
ServiceStack.Caching.ICacheClientAsynccache
System.Stringkey
System.TimeSpanexpiresIn
System.Func<System.Threading.Tasks.Task<<T>>>createFn
Type Parameters
  • T

GetTimeToLive(ICacheClient, String)

View Source
Declaration
public static TimeSpan? GetTimeToLive(this ICacheClient cache, string key)
Returns

System.Nullable<System.TimeSpan>

Parameters
TypeName
ServiceStack.Caching.ICacheClientcache
System.Stringkey