示例#1
0
 public static IDocumentStore SetUpConfigurableAggressiveCaching(
     this IDocumentStore store,
     IDictionary <string, TimeSpan> initialProfiles = null)
 {
     AggressiveCachingSettings.Subscribe(store, initialProfiles);
     return(store);
 }
        internal static void Subscribe(IDocumentStore store, IDictionary <string, TimeSpan> defaults)
        {
            store.Ensure("store").IsNotNull();

            var settings = new AggressiveCachingSettings(defaults);

            settings.store = store;
            store.SetProperty(AggressiveCachingSettings.StorePropertyKey, settings);

            store.Changes()
            .ForDocument(LiveId)
            .Subscribe(new DocumentChangeObserver(_ => settings.LoadFromStore()));
        }
示例#3
0
        public static IDisposable AggressivelyCacheFor(
            this IDocumentStore store,
            string cacheProfileName)
        {
            var cacheDuration = AggressiveCachingSettings.ForStore(store)
                                .GetCacheDuration(cacheProfileName)
                                ?? store.JsonRequestFactory.AggressiveCacheDuration;

            if (cacheDuration.HasValue &&
                minCacheTimeAllowedByRaven <= cacheDuration.Value)
            {
                return(store.AggressivelyCacheFor(cacheDuration.Value));
            }
            else
            {
                return(new DisposableAction(() => { }));
            }
        }