@@ -74,13 +74,13 @@ public async Task<IEnumerable<Alias>> GetAllAsync(Guid? siteId = null)
7474 /// <returns>The model, or null if it doesn't exist</returns>
7575 public async Task < Alias > GetByIdAsync ( Guid id )
7676 {
77- var model = _cache ? . Get < Alias > ( id . ToString ( ) ) ;
77+ var model = _cache == null ? null : await _cache . GetAsync < Alias > ( id . ToString ( ) ) . ConfigureAwait ( false ) ;
7878
7979 if ( model == null )
8080 {
8181 model = await _repo . GetById ( id ) . ConfigureAwait ( false ) ;
8282
83- OnLoad ( model ) ;
83+ await OnLoad ( model ) . ConfigureAwait ( false ) ;
8484 }
8585 return model ;
8686 }
@@ -182,7 +182,7 @@ public async Task SaveAsync(Alias model)
182182 App . Hooks . OnAfterSave ( model ) ;
183183
184184 // Remove from cache
185- RemoveFromCache ( model ) ;
185+ await RemoveFromCache ( model ) . ConfigureAwait ( false ) ;
186186 }
187187
188188 /// <summary>
@@ -211,36 +211,38 @@ public async Task DeleteAsync(Alias model)
211211 App . Hooks . OnAfterDelete ( model ) ;
212212
213213 // Remove from cache
214- RemoveFromCache ( model ) ;
214+ await RemoveFromCache ( model ) . ConfigureAwait ( false ) ;
215215 }
216216
217217 /// <summary>
218218 /// Processes the model on load.
219219 /// </summary>
220220 /// <param name="model">The model</param>
221- private void OnLoad ( Alias model )
221+ private Task OnLoad ( Alias model )
222222 {
223223 if ( model != null )
224224 {
225225 App . Hooks . OnLoad ( model ) ;
226226
227227 if ( _cache != null )
228228 {
229- _cache . Set ( model . Id . ToString ( ) , model ) ;
229+ return _cache . SetAsync ( model . Id . ToString ( ) , model ) ;
230230 }
231231 }
232+
233+ return Task . CompletedTask ;
232234 }
233235
234236 /// <summary>
235237 /// Removes the given model from cache.
236238 /// </summary>
237239 /// <param name="model">The model</param>
238- private void RemoveFromCache ( Alias model )
240+ private async Task RemoveFromCache ( Alias model )
239241 {
240242 if ( _cache != null )
241243 {
242- _cache . Remove ( model . Id . ToString ( ) ) ;
243- _cache . Remove ( $ "Piranha_AliasUrls_{ model . SiteId } ") ;
244+ await _cache . RemoveAsync ( model . Id . ToString ( ) ) . ConfigureAwait ( false ) ;
245+ await _cache . RemoveAsync ( $ "Piranha_AliasUrls_{ model . SiteId } ") . ConfigureAwait ( false ) ;
244246 }
245247 }
246248
@@ -251,7 +253,7 @@ private async Task<IEnumerable<AliasUrlCacheEntry>> GetAliasUrls(Guid siteId)
251253 {
252254 if ( _cache != null )
253255 {
254- var aliasUrls = _cache . Get < IEnumerable < AliasUrlCacheEntry > > ( $ "Piranha_AliasUrls_{ siteId } ") ;
256+ var aliasUrls = await _cache . GetAsync < IEnumerable < AliasUrlCacheEntry > > ( $ "Piranha_AliasUrls_{ siteId } ") . ConfigureAwait ( false ) ;
255257
256258 if ( aliasUrls == null )
257259 {
@@ -262,7 +264,7 @@ private async Task<IEnumerable<AliasUrlCacheEntry>> GetAliasUrls(Guid siteId)
262264 AliasUrl = x . AliasUrl
263265 } ) . ToList ( ) ;
264266
265- _cache . Set ( $ "Piranha_AliasUrls_{ siteId } ", aliasUrls ) ;
267+ await _cache . SetAsync ( $ "Piranha_AliasUrls_{ siteId } ", aliasUrls ) . ConfigureAwait ( false ) ;
266268 }
267269 return aliasUrls ;
268270 }
0 commit comments