public DocumentCache(IDocumentStore store, ICacheAllocator cacheAllocator, bool ignoreIgnoreCache = false) { Store = store; Allocator = cacheAllocator; Root = new AsyncLazy <ICollection>(() => Task.FromResult <ICollection>(null)); IgnoreIgnoreCache = ignoreIgnoreCache; cacheAllocator.OnDeallocate.Add((x) => Store.Remove(x)); }
public DocumentPredictor(IDocumentStore store, IDocumentPredictor predictor, ICacheAllocator allocator, ChainedFileSystem predictOnFileSystem) { Store = store; Predictor = predictor; Allocator = allocator; Allocator.OnDeallocate.Add(async(x) => { await Store.Remove(x); }); ThreadPool.QueueUserWorkItem(async(x) => { try { RequestLockManager.LockAndWait("DocumentPredictor_ctor"); while (FileSystem == null) { await Task.Delay(10); } await PredicitiveFillCache(0, CancellationToken.None); }finally{ RequestLockManager.Unlock("DocumentPredictor_ctor"); } }); }
public static Task <float> FitnessToAllocateAsync(this ICacheAllocator inv, string name, Func <Task <IDocument> > doc) => inv.FitnessToAllocateAsync(name, doc, async() => { IDocument d = await doc(); return(await d.OpenReadAsync(CancellationToken.None)); });
public static Task Refresh(this ICacheAllocator inv, string name, Func <Task <IDocument> > doc, Func <Task <Stream> > result) => inv.Refresh(name, doc, async() => { IDocument d = await doc(); return(await d.OpenReadAsync(CancellationToken.None)); });
public ManagedCache(IDocumentStore store, ICacheAllocator allocator) : this(new DocumentCache(store, allocator)) { }