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;
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 {
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:17
bool Standalone
If cache is a standalone cache, or if it can be managed collectively with other caches.
Definition: Cache.cs:109
ICollection< ValueType > Values
Values in cache.
Definition: Cache.cs:355
bool Remove(KeyType Key)
Removes an item from the cache.
Definition: Cache.cs:616
void Clear()
Clears the cache.
Definition: Cache.cs:679
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
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
void Add(T Item)
Adds an item to the collection.
Definition: ChunkedList.cs:272
T[] ToArray()
Returns an array containing all elements of the collection.
Interface for caches.
Definition: ICache.cs:9