Esempio n. 1
0
 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));
 }
Esempio n. 2
0
        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");
                }
            });
        }
Esempio n. 3
0
 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));
 });
Esempio n. 4
0
 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));
 });
Esempio n. 5
0
 public ManagedCache(IDocumentStore store, ICacheAllocator allocator) :
     this(new DocumentCache(store, allocator))
 {
 }