forked from SharpRepository/SharpRepository
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCache.cs
More file actions
30 lines (26 loc) · 1.47 KB
/
Copy pathCache.cs
File metadata and controls
30 lines (26 loc) · 1.47 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
using System;
namespace SharpRepository.Repository.Caching
{
public static class Cache
{
public static ICachePrefixManager CachePrefixManager { get; set; }
internal static int GlobalCachingPrefixCounter
{
get
{
return CachePrefixManager == null ? 1 : CachePrefixManager.Counter;
}
}
/// <summary>
/// This will clear out all SharpRepository related caching across all of the repositories. You must configure the Cache.CachePrefixManager property based on if your code is on a single server or in a multiple server farm or cloud environment.
/// </summary>
public static void ClearAll()
{
if (CachePrefixManager == null)
throw new Exception("You must configure the Cache.CachePrefixManager in order to handle clearing the global cache. You can use the SingleServerCachePrefixManager if you are on a single server, and the MultiServerCachePrefixManager if you are in the cloud or on multiple servers and use a caching provider like Memcached or Redis.");
// this increments a static counter by 1
// the static counter is used for all of the cache keys as part of the prefix
CachePrefixManager.IncrementCounter();
}
}
}