@@ -20,16 +20,23 @@ public abstract class DistributedCache<TCacheId> : IDistributedCache<TCacheId>
2020 private const int MaxCacheKeyBytes = 250 ;
2121
2222 /// <summary>
23- /// Gets the name of the cache .
23+ /// Indicates whether cache keys should be URL-encoded .
2424 /// </summary>
25- /// <value>
26- /// The name of the cache.
27- /// </value>
28- private static string CacheIdName => typeof ( TCacheId ) . Name ;
29-
3025 private readonly bool enableKeyEncoding ;
26+
27+ /// <summary>
28+ /// Indicates whether cache key length validation is enabled.
29+ /// </summary>
3130 private readonly bool enableKeyLengthValidation ;
31+
32+ /// <summary>
33+ /// The cache key version for invalidation purposes.
34+ /// </summary>
3235 private readonly int ? version ;
36+
37+ /// <summary>
38+ /// The environment prefix for cache key isolation.
39+ /// </summary>
3340 private readonly string ? environmentPrefix ;
3441
3542 /// <summary>
@@ -71,127 +78,135 @@ protected DistributedCache(IOptions<DistributedCacheOptionsBase> optionsAccessor
7178 /// </summary>
7279 protected string ? EnvironmentPrefix => this . environmentPrefix ;
7380
81+ /// <summary>
82+ /// Gets the name of the cache.
83+ /// </summary>
84+ /// <value>
85+ /// The name of the cache.
86+ /// </value>
87+ private static string CacheIdName => typeof ( TCacheId ) . Name ;
88+
7489 /// <inheritdoc />
7590 public T ? Get < T > ( TCacheId id )
7691 where T : class
7792 {
78- var cacheKey = CreateCacheKey ( id ) ;
93+ var cacheKey = this . CreateCacheKey ( id ) ;
7994 return this . GetCacheObject < T > ( cacheKey ) ;
8095 }
8196
8297 /// <inheritdoc />
8398 public T ? Get < T > ( TCacheId id , string key )
8499 where T : class
85100 {
86- var cacheKey = CreateCacheKey ( id , key ) ;
101+ var cacheKey = this . CreateCacheKey ( id , key ) ;
87102 return this . GetCacheObject < T > ( cacheKey ) ;
88103 }
89104
90105 /// <inheritdoc />
91106 public Task < T ? > GetAsync < T > ( TCacheId id , CancellationToken token = default )
92107 where T : class
93108 {
94- var cacheKey = CreateCacheKey ( id ) ;
109+ var cacheKey = this . CreateCacheKey ( id ) ;
95110 return this . GetCacheObjectAsync < T > ( cacheKey , token ) ;
96111 }
97112
98113 /// <inheritdoc />
99114 public Task < T ? > GetAsync < T > ( TCacheId id , string key , CancellationToken token = default )
100115 where T : class
101116 {
102- var cacheKey = CreateCacheKey ( id , key ) ;
117+ var cacheKey = this . CreateCacheKey ( id , key ) ;
103118 return this . GetCacheObjectAsync < T > ( cacheKey , token ) ;
104119 }
105120
106121 /// <inheritdoc />
107122 public void Set < T > ( TCacheId id , T value )
108123 where T : class
109124 {
110- var cacheKey = CreateCacheKey ( id ) ;
125+ var cacheKey = this . CreateCacheKey ( id ) ;
111126 this . SetCacheObject ( cacheKey , value , new CacheEntryOptions ( ) ) ;
112127 }
113128
114129 /// <inheritdoc />
115130 public void Set < T > ( TCacheId id , string key , T value )
116131 where T : class
117132 {
118- var cacheKey = CreateCacheKey ( id , key ) ;
133+ var cacheKey = this . CreateCacheKey ( id , key ) ;
119134 this . SetCacheObject ( cacheKey , value , new CacheEntryOptions ( ) ) ;
120135 }
121136
122137 /// <inheritdoc />
123138 public Task SetAsync < T > ( TCacheId id , T value , CancellationToken token = default )
124139 where T : class
125140 {
126- var cacheKey = CreateCacheKey ( id ) ;
141+ var cacheKey = this . CreateCacheKey ( id ) ;
127142 return this . SetCacheObjectAsync ( cacheKey , value , new CacheEntryOptions ( ) , token ) ;
128143 }
129144
130145 /// <inheritdoc />
131146 public Task SetAsync < T > ( TCacheId id , string key , T value , CancellationToken token = default )
132147 where T : class
133148 {
134- var cacheKey = CreateCacheKey ( id , key ) ;
149+ var cacheKey = this . CreateCacheKey ( id , key ) ;
135150 return this . SetCacheObjectAsync ( cacheKey , value , new CacheEntryOptions ( ) , token ) ;
136151 }
137152
138153 /// <inheritdoc />
139154 public void SetWithOptions < T > ( TCacheId id , T value , CacheEntryOptions ? options )
140155 where T : class
141156 {
142- var cacheKey = CreateCacheKey ( id ) ;
157+ var cacheKey = this . CreateCacheKey ( id ) ;
143158 this . SetCacheObject ( cacheKey , value , options ) ;
144159 }
145160
146161 /// <inheritdoc />
147162 public void SetWithOptions < T > ( TCacheId id , string key , T value , CacheEntryOptions ? options )
148163 where T : class
149164 {
150- var cacheKey = CreateCacheKey ( id , key ) ;
165+ var cacheKey = this . CreateCacheKey ( id , key ) ;
151166 this . SetCacheObject ( cacheKey , value , options ) ;
152167 }
153168
154169 /// <inheritdoc />
155170 public Task SetWithOptionsAsync < T > ( TCacheId id , T value , CacheEntryOptions ? options , CancellationToken token = default )
156171 where T : class
157172 {
158- var cacheKey = CreateCacheKey ( id ) ;
173+ var cacheKey = this . CreateCacheKey ( id ) ;
159174 return this . SetCacheObjectAsync ( cacheKey , value , options , token ) ;
160175 }
161176
162177 /// <inheritdoc />
163178 public Task SetWithOptionsAsync < T > ( TCacheId id , string key , T value , CacheEntryOptions ? options , CancellationToken token = default )
164179 where T : class
165180 {
166- var cacheKey = CreateCacheKey ( id , key ) ;
181+ var cacheKey = this . CreateCacheKey ( id , key ) ;
167182 return this . SetCacheObjectAsync ( cacheKey , value , options , token ) ;
168183 }
169184
170185 /// <inheritdoc />
171186 public void Remove ( TCacheId id )
172187 {
173- var cacheKey = CreateCacheKey ( id ) ;
188+ var cacheKey = this . CreateCacheKey ( id ) ;
174189 this . RemoveCacheObject ( cacheKey ) ;
175190 }
176191
177192 /// <inheritdoc />
178193 public void Remove ( TCacheId id , string key )
179194 {
180- var cacheKey = CreateCacheKey ( id , key ) ;
195+ var cacheKey = this . CreateCacheKey ( id , key ) ;
181196 this . RemoveCacheObject ( cacheKey ) ;
182197 }
183198
184199 /// <inheritdoc />
185200 public Task RemoveAsync ( TCacheId id , CancellationToken token = default )
186201 {
187- var cacheKey = CreateCacheKey ( id ) ;
202+ var cacheKey = this . CreateCacheKey ( id ) ;
188203 return this . RemoveCacheObjectAsync ( cacheKey , token ) ;
189204 }
190205
191206 /// <inheritdoc />
192207 public Task RemoveAsync ( TCacheId id , string key , CancellationToken token = default )
193208 {
194- var cacheKey = CreateCacheKey ( id , key ) ;
209+ var cacheKey = this . CreateCacheKey ( id , key ) ;
195210 return this . RemoveCacheObjectAsync ( cacheKey , token ) ;
196211 }
197212
0 commit comments