src/fursvp.data/RepositoryDecorators/CachingRepository.cs
/// <summary>
/// Gets a result set containing all documents for the entity type from the cache, or via the decorated method if not yet cached.
/// If not already cached, then an index is built and the index and all entities retrieved are cached.
/// </summary>
/// <returns>An <see cref="IQueryable{T}"/> against which further filtering can be applied on the result set.</returns>
Gets a result set containing all documents for the entity type from the cache, or via the decorated method if not yet cached.
If not already cached, then an index is built and the index and all entities retrieved are cached.
Gets a result set containing all documents for the entity type from the cache or via the decorated method if not yet cached . If not already cached then an index is built and the index and all entities retrieved are cached .
public async Task<IQueryable<T>> GetAll()
        {
            if (MemoryCache.TryGetValue(IndexCacheKey, out List<Guid> guids))
            {
                return guids.Select(g =>
                {
                    var entity = MemoryCache.Get<T>(g);
                    return Mapper.Map<T, T>(entity);
                }).AsQueryable();
            }
            var allEntities = (await Decorated.GetAll().ConfigureAwait(false)).ToList();
            DateTime expiration = DateTime.Now.AddMinutes(5); 
            MemoryCache.Set(IndexCacheKey, allEntities.Select(e => e.Id).ToList(), expiration);
            foreach (var e in allEntities)
            {
                CacheCopyOfEntity(e, expiration);
            }
            return allEntities.AsQueryable();
        }
public async Task < IQueryable < T > > GetAll ( ) { if ( MemoryCache . TryGetValue ( IndexCacheKey , out List < Guid > guids ) ) { return guids . Select ( g => { var entity = MemoryCache . Get < T > ( g ) ; return Mapper . Map < T , T > ( entity ) ; } ) . AsQueryable ( ) ; } var allEntities = ( await Decorated . GetAll ( ) . ConfigureAwait ( false ) ) . ToList ( ) ; DateTime expiration = DateTime . Now . AddMinutes ( 5 ) ; MemoryCache . Set ( IndexCacheKey , allEntities . Select ( e => e . Id ) . ToList ( ) , expiration ) ; foreach ( var e in allEntities ) { CacheCopyOfEntity ( e , expiration ) ; } return allEntities . AsQueryable ( ) ; }
Gets a result set containing all documents for the entity type from the cache, or via the decorated method if not yet cached.
Gets a result set containing all documents for the entity type from the cache or via the decorated method if not yet cached .
// TODO - put magic number into config
An  against which further filtering can be applied on the result set.
An against which further filtering can be applied on the result set .