src/fursvp.data/RepositoryDecorators/CachingRepository.cs
/// <summary>
/// Gets a single instance of T matching the given Id from the cache, or via the decorated method if not already cached.
/// If not already cached, the entity retrieved is cached.
/// </summary>
/// <param name="guid">The globally unique identifier for the entity.</param>
/// <returns>An asynchronous <see cref="Task{T}"/> containing the entity if found, otherwise null.</returns>
Gets a single instance of T matching the given Id from the cache, or via the decorated method if not already cached.
If not already cached, the entity retrieved is cached.
Gets a single instance of T matching the given Id from the cache or via the decorated method if not already cached . If not already cached the entity retrieved is cached .
public async Task<T> GetById(Guid guid)
        {
            var entity = await MemoryCache.GetOrCreateAsync(guid, async entry =>
            {
                entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5); 
                return await Decorated.GetById(guid).ConfigureAwait(false);
            }).ConfigureAwait(false);
            return Mapper.Map<T, T>(entity);
        }
public async Task < T > GetById ( Guid guid ) { var entity = await MemoryCache . GetOrCreateAsync ( guid , async entry => { entry . AbsoluteExpirationRelativeToNow = TimeSpan . FromMinutes ( 5 ) ; return await Decorated . GetById ( guid ) . ConfigureAwait ( false ) ; } ) . ConfigureAwait ( false ) ; return Mapper . Map < T , T > ( entity ) ; }
Gets a single instance of T matching the given Id from the cache, or via the decorated method if not already cached.
Gets a single instance of T matching the given Id from the cache or via the decorated method if not already cached .
// TODO - put magic number into config
An asynchronous  containing the entity if found, otherwise null.
An asynchronous containing the entity if found otherwise null .
guid
Guid
The globally unique identifier for the entity.
The globally unique identifier for the entity .