forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathICachedServiceClient.cs
More file actions
43 lines (39 loc) · 1.37 KB
/
ICachedServiceClient.cs
File metadata and controls
43 lines (39 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#if !SL5
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace ServiceStack
{
public interface ICachedServiceClient : IServiceClient
{
int CacheCount { get; }
long CacheHits { get; }
long NotModifiedHits { get; }
long ErrorFallbackHits { get; }
long CachesAdded { get; }
long CachesRemoved { get; }
void SetCache(ConcurrentDictionary<string, HttpCacheEntry> cache);
int RemoveCachesOlderThan(TimeSpan age);
int RemoveExpiredCachesOlderThan(TimeSpan age);
}
public static class ICachedServiceClientExtensions
{
public static void ClearCache(this ICachedServiceClient client)
{
client.SetCache(new ConcurrentDictionary<string, HttpCacheEntry>());
}
public static Dictionary<string, string> GetStats(this ICachedServiceClient client)
{
return new Dictionary<string,string>
{
{ "CacheCount", client.CacheCount + "" },
{ "CacheHits", client.CacheHits + "" },
{ "NotModifiedHits", client.NotModifiedHits + "" },
{ "ErrorFallbackHits", client.ErrorFallbackHits + "" },
{ "CachesAdded", client.CachesAdded + "" },
{ "CachesRemoved", client.CachesRemoved + "" },
};
}
}
}
#endif