22![ semver] ( https://img.shields.io/badge/semver-1.3.0-blue )
33
44# AutoIndexCache
5- A thread-safe, lazy-loading cache for .NET applications that provides automatic indexing of the cached items .
5+ A high-performance, thread-safe cache for .NET applications that provides automatic indexing of cached data .
66
77``` csharp
88using System ;
@@ -20,7 +20,7 @@ public class Program
2020{
2121 public static void Main (String [] args )
2222 {
23- var cache = new AutoIndexCache ();
23+ var cache = new AutoIndexCache . AutoIndexCache ();
2424
2525 cache .SetItemsLoader (() => LoadUsers ());
2626
@@ -89,9 +89,7 @@ So instead of this:
8989``` csharp
9090class Service
9191{
92- private readonly AutoIndexCache cache ;
93-
94- public Service (AutoIndexCache cache )
92+ public Service (IAutoIndexCache cache )
9593 {
9694 this .cache = cache ;
9795 }
@@ -100,18 +98,16 @@ class Service
10098 {
10199 return this .cache .Items <User >().UniqueIndex (a => a .Id ).GetItemOrDefault (id );
102100 }
101+
102+ private readonly IAutoIndexCache cache ;
103103}
104104```
105105
106106you do this:
107107``` csharp
108108class Service
109109{
110- private readonly AutoIndexCache cache ;
111- private readonly IItemList <User > users ;
112- private readonly IUniqueIndex <User , Int32 > userById ;
113-
114- public Service (AutoIndexCache cache )
110+ public Service (IAutoIndexCache cache )
115111 {
116112 this .cache = cache ;
117113 this .users = this .cache .Items <User >();
@@ -122,6 +118,10 @@ class Service
122118 {
123119 return this .userById .GetItemOrDefault (id );
124120 }
121+
122+ private readonly IAutoIndexCache cache ;
123+ private readonly IUniqueIndex <User , Int64 > userById ;
124+ private readonly IItemsList <User > users ;
125125}
126126```
127127
0 commit comments