Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Caches.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
4
6{
10 public static class Caches
11 {
12 private static readonly Dictionary<Guid, ICache> caches = new Dictionary<Guid, ICache>();
13
14 internal static void Register(Guid Guid, ICache Cache)
15 {
16 lock (caches)
17 {
18 caches[Guid] = Cache;
19 }
20 }
21
22 internal static bool Unregister(Guid Guid)
23 {
24 lock (caches)
25 {
26 return caches.Remove(Guid);
27 }
28 }
29
34 public static ICache[] GetCaches()
35 {
36 return GetCaches(true);
37 }
38
44 public static ICache[] GetCaches(bool ExcludeStandalone)
45 {
46 List<ICache> Result = new List<ICache>();
47
48 lock (caches)
49 {
50 foreach (ICache Cache in caches.Values)
51 {
52 if (ExcludeStandalone && Cache.Standalone)
53 continue;
54
55 Result.Add(Cache);
56 }
57 }
58
59 return Result.ToArray();
60 }
61
65 public static void ClearAll()
66 {
67 ClearAll(true);
68 }
69
74 public static void ClearAll(bool ExcludeStandalone)
75 {
76 foreach (ICache Cache in GetCaches(ExcludeStandalone))
77 Cache.Clear();
78 }
79 }
80}
Implements an in-memory cache.
Definition: Cache.cs:15
bool Standalone
If cache is a standalone cache, or if it can be managed collectively with other caches.
Definition: Cache.cs:84
ICollection< ValueType > Values
Values in cache.
Definition: Cache.cs:247
bool Remove(KeyType Key)
Removes an item from the cache.
Definition: Cache.cs:451
void Clear()
Clears the cache.
Definition: Cache.cs:484
Repository of all active caches.
Definition: Caches.cs:11
static ICache[] GetCaches()
Gets active caches.
Definition: Caches.cs:34
static void ClearAll()
Clears all active caches.
Definition: Caches.cs:65
static void ClearAll(bool ExcludeStandalone)
Clears all active caches.
Definition: Caches.cs:74
static ICache[] GetCaches(bool ExcludeStandalone)
Gets active caches.
Definition: Caches.cs:44
Interface for caches.
Definition: ICache.cs:9