/// <summary> /// Begins an asynchronous request /// </summary> /// <param name="useCache">true to use cache, otherwise false</param> /// <param name="timeOut">timeout, in milliseconds</param> public void StartRequest(CacheSettings cacheSettings, int timeOut) { requestRunning = true; // Check the cache if (cacheSettings != CacheSettings.NOCACHE) { Internet_Cache_Entry_Info cacheInfo; if (WinInet.GetUrlCacheEntryInfo(m_url, out cacheInfo)) { ResponseStream = new FileStream(cacheInfo.lpszLocalFileName, FileMode.Open, FileAccess.Read); FireRequestComplete(); } } // Make an async request if (ResponseStream == null && cacheSettings != CacheSettings.CACHEONLY) { try { m_webRequest = HttpRequestHelper.CreateHttpWebRequest(m_url, true); } catch (InvalidCastException) { m_webRequest = WebRequest.Create(m_url); } m_webRequest.Timeout = timeOut; m_webRequest.BeginGetResponse(new AsyncCallback(RequestCompleteHandler), new object()); } }
/// <summary> /// Generates a trie of suggestions based on attributes of packages in the catalog /// </summary> /// <param name="client"></param> /// <param name="searchParameters"></param> /// <param name="cacheSettings"></param> /// <returns></returns> private static Trie GenerateTrie(CkanClient client, PackageSearchParameters searchParameters, CacheSettings cacheSettings) { // Create an empty trie Trie trie = new Trie(); // Run the search to get all packages PackageSearchResponse<Package> response = client.SearchPackages<Package>(searchParameters, cacheSettings); // Add the entrys to the trie foreach (var package in response.Results) { // Add the package title trie.Add(package.Title); // Add the package tags (removing hyphens which represent spaces) foreach (var tag in package.Tags) { trie.Add(tag.Replace("-"," ")); } } return trie; }
/// <summary> /// Gets a trie of package search suggestions a package search. /// If cached, the trie will be returned from the /// cache, otherwise it will be created and cached. /// </summary> /// <param name="client"></param> /// <param name="searchParameters"></param> /// <param name="cacheSettings"></param> /// <returns></returns> public static Trie GetTrie(CkanClient client, PackageSearchParameters searchParameters, CacheSettings cacheSettings) { Trie trie = null; // Get the trie from the cache string key = CkanClient.CacheKeyPrefix + "AutoComplete"; // Get the memorycache MemoryCache cache = MemoryCache.Default; // Get the cached entry if it exists CacheEntry cacheEntry = cache[key] as CacheEntry; if (cacheEntry == null) { // Generate the trie trie = GenerateTrie(client, searchParameters, cacheSettings); cacheEntry = new CacheEntry(); cacheEntry.Data = trie; cacheEntry.Label = "Autocomplete index"; cacheEntry.LastCached = DateTime.Now; cacheEntry.Duration = cacheSettings.Duration; CacheItemPolicy policy = new CacheItemPolicy(); policy.AbsoluteExpiration = DateTimeOffset.Now.Add(cacheSettings.Duration); // Add the trie to the cache cache.Set(key, cacheEntry, policy); } else { // Get the trie from the cache trie = (Trie)cacheEntry.Data; } return trie; }
public DomainServiceResolver(string agentName, ClientSettings domainClientSettings, CacheSettings cacheSettings) { if (agentName == null) { throw new ArgumentNullException("agentName"); } if (domainClientSettings == null) { throw new ArgumentNullException("domainClientSettings"); } m_agentName = agentName; m_domainClientSettings = domainClientSettings; if (cacheSettings != null && cacheSettings.Cache) { CacheSettings agentDomainCacheSettings = new CacheSettings(cacheSettings) { Name = "AgentDomainCache" }; m_domainCache = new DomainCache(agentDomainCacheSettings); } }
public Settings() { update = new UpdateSettings(); task = new TaskSettings(); cache = new CacheSettings(); }
/// <summary> /// Provides for defering the execution of the <paramref name="source"/> query to a batch of future queries. /// </summary> /// <typeparam name="T">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">An <see cref="T:System.Linq.IQueryable`1"/> to add to the batch of future queries.</param> /// <param name="cacheSettings">The cache settings.</param> /// <returns> /// An instance of <see cref="FutureCount"/> that contains the result of the query. /// </returns> /// <seealso cref="T:CodeSmith.Data.Linq.FutureCount"/> public static IFutureValue <int> FutureCacheCount <T>(this IQueryable <T> source, CacheSettings cacheSettings) { if (source == null) { return(new LoadedFutureValue <int>(0, source)); } var db = source.GetFutureConext(); return(db.FutureCount(source, cacheSettings)); }
public TriggerInvalidation(string groupName, CacheSettings settings) : this(groupName, settings, string.Empty) { }
/// <remarks> /// The <see cref="RedisLockExtension"/> attempts to set a key in Redis representing whether it has achieved a lock. /// If it succeeds to set the key, it continues to refresh the value, broadcasting the success of the updated value to all subscribers. /// If it fails to set the key, it waits until notified that the cache is updated, retrieving it from the cache stack and returning the value. /// </remarks> /// <inheritdoc/> public async ValueTask <CacheEntry <T> > WithRefreshAsync <T>(string cacheKey, Func <ValueTask <CacheEntry <T> > > valueProvider, CacheSettings settings) { var lockKey = string.Format(Options.KeyFormat, cacheKey); var hasLock = await Database.StringSetAsync(lockKey, RedisValue.EmptyString, expiry : Options.LockTimeout, when : When.NotExists); if (hasLock) { try { var cacheEntry = await valueProvider(); await Subscriber.PublishAsync(Options.RedisChannel, cacheKey, CommandFlags.FireAndForget); return(cacheEntry); } finally { await Database.KeyDeleteAsync(lockKey, CommandFlags.FireAndForget); } } else { var completionSource = LockedOnKeyRefresh.GetOrAdd(cacheKey, key => new TaskCompletionSource <bool>()); //Last minute check to confirm whether waiting is required (in case the notification is missed) var currentEntry = await RegisteredStack !.GetAsync <T>(cacheKey); if (currentEntry != null && currentEntry.GetStaleDate(settings) > Internal.DateTimeProvider.Now) { UnlockWaitingTasks(cacheKey); return(currentEntry); } //Lock until we are notified to be unlocked await completionSource.Task; //Get the updated value from the cache stack return((await RegisteredStack.GetAsync <T>(cacheKey)) !); } }
public TData Cache <TData>(Func <CacheSettings, TData> loadMethod, CacheSettings settings) => CacheHelper.Cache(loadMethod, settings);
private CacheSettings GetCacheSettings() { Log.Verbose("Getting cache settings by tenant based profile."); var settings = new CacheSettings { Duration = this.Duration, Location = this.Location, NoStore = this.NoStore, Options = this.Options, VaryByCustom = this.VaryByCustom, VaryByParam = this.VaryByParam }; if (this.Duration > 0) { settings.IsCachingEnabled = true; } string profile = this.ProfileName; if (string.IsNullOrWhiteSpace(profile)) { Log.Verbose("Aborted creating cache settings because the current cache profile name is empty."); return(settings); } Log.Verbose("Setting the \"CacheProfile\" to an empty value to override the behavior of DonutCache."); this.CacheProfile = string.Empty; string tenant = TenantConvention.GetTenant(); Log.Verbose("The current tenant is {tenant}.", tenant); Log.Verbose("Getting cache config for current tenant \"{tenant}\" and profile \"{profile}\".", tenant, profile); var config = CacheConfig.Get(tenant, profile); if (config == null) { Log.Verbose("Could not find any cache config information for current tenant \"{tenant}\" and profile \"{profile}\".", tenant, profile); return(settings); } Log.Verbose("The cache duration for tenant \"{tenant}\" and profile \"{profile}\" is {Duration}", tenant, profile, config.Duration); settings.Duration = config.Duration; Log.Verbose("The cache location for tenant \"{tenant}\" and profile \"{profile}\" is {Location}", tenant, profile, config.Location); settings.Location = config.Location; Log.Verbose("The cache NoStore value for tenant \"{tenant}\" and profile \"{profile}\" is {NoStore}", tenant, profile, config.NoStore); settings.NoStore = config.NoStore; Log.Verbose("The cache VaryByCustom value for tenant \"{tenant}\" and profile \"{profile}\" is {VaryByCustom}", tenant, profile, config.VaryByCustom); settings.VaryByCustom = config.VaryByCustom; Log.Verbose("The cache VaryByParam value for tenant \"{tenant}\" and profile \"{profile}\" is {VaryByParam}", tenant, profile, config.VaryByParam); settings.VaryByParam = config.VaryByParam; Log.Verbose("The cache Options value for tenant \"{tenant}\" and profile \"{profile}\" is {Options}", tenant, profile, config.Options); settings.Options = config.Options; settings.IsCachingEnabled = settings.Duration > 0; return(settings); }
public Cacheable(String groupName, CacheSettings settings, String parameterProperty) { KeyBuilder.GroupName = groupName; KeyBuilder.Settings = settings; KeyBuilder.ParameterProperty = parameterProperty; }
protected override void SetCacheSettings(IContent content, CacheSettings cacheSettings) { // Make the cache of this content provider depend on the original content cacheSettings.CacheKeys.Add(DataFactoryCache.PageCommonCacheKey(new ContentReference(content.ContentLink.ID))); }
/// <summary> /// Converts the profile element to a <see cref="CacheSettings"/> instance. /// </summary> /// <returns>An instance of <see cref="CacheSettings"/>.</returns> public CacheSettings ToCacheSettings() { var cache = new CacheSettings(); cache.Duration = Duration; cache.Mode = Mode; if (!string.IsNullOrEmpty(Provider)) cache.Provider = Provider; if (!string.IsNullOrEmpty(Group)) cache.Group = Group; return cache; }
/// <summary>Parametrized cache constructor allowing to specify groups of cache and cache settings</summary> /// <param name="groupName">Name of group which should contain the cached value</param> /// <param name="settings">TBD</param> public Cacheable(string groupName, CacheSettings settings) : this(groupName, settings, string.Empty) { }
/// <summary>Parametrized cache constructor allowing to specify groups of cache and cache settings</summary> /// <param name="groupName"></param> /// <param name="settings"></param> /// <param name="parameterProperty"></param> public Cacheable(string groupName, CacheSettings settings, string parameterProperty) { KeyBuilder.GroupName = groupName; KeyBuilder.Settings = settings; KeyBuilder.ParameterProperty = parameterProperty; }
protected override void SetCacheSettings(ContentReference contentReference, IEnumerable<ContentReference> children, CacheSettings cacheSettings) { // Make the cache of this content provider depend on the original content cacheSettings.CacheKeys.Add(DataFactoryCache.PageCommonCacheKey(new ContentReference(contentReference.ID))); foreach (var child in children) { cacheSettings.CacheKeys.Add(DataFactoryCache.PageCommonCacheKey(new ContentReference(child.ID))); } }
IFutureValue <T> IFutureContext.FutureFirstOrDefault <T>(IQueryable <T> query, CacheSettings cacheSettings) { var action = new Action(ExecuteFutureQueries); var future = new FutureValue <T>(query, action, cacheSettings); _futureQueries.Add(future); return(future); }
/// <summary> /// Synchronously retrieves a response stream for this request /// </summary> /// <param name="timeOut">timeout, in ms</param> /// <param name="useCache">true to use cache, otherwise false</param> /// <returns>The stream</returns> public Stream GetResponseStream(CacheSettings cacheSettings, int timeOut) { Stream stream = Stream.Null; // Check the cache if (cacheSettings != CacheSettings.NOCACHE) { Internet_Cache_Entry_Info cacheInfo; if (WinInet.GetUrlCacheEntryInfo(m_url, out cacheInfo)) { if (File.Exists(cacheInfo.lpszLocalFileName)) { stream = new FileStream(cacheInfo.lpszLocalFileName, FileMode.Open, FileAccess.Read); } } } // Make a synchronous request, if necessary if (stream == Stream.Null && cacheSettings != CacheSettings.CACHEONLY) { if (m_url == null) return null; if (WebRequest is HttpWebRequest) { HttpWebRequest thisRequest = (HttpWebRequest)WebRequest; thisRequest.Timeout = timeOut; } try { stream = WebRequest.GetResponse().GetResponseStream(); } catch (WebException) { } } return stream; }
public object Clone() { CacheServerConfig config = new CacheServerConfig(); config.cacheSettings = CacheSettings != null ? (CacheServerConfigSetting)CacheSettings.Clone() : null; config.cacheDeployment = CacheDeployment != null ? (CacheDeployment)CacheDeployment.Clone() : null; config.ConfigID = ConfigID; config.configVersion = configVersion; config.IsRegistered = this.IsRegistered; config.IsRunning = this.IsRunning; config.licenseIsExpired = this.licenseIsExpired; config.name = this.name; config._alias = this._alias; return(config); }
/// <summary> /// Synchronously retrieves a response stream for this request /// </summary> /// <param name="useCache">true to use cache, otherwise false</param> /// <returns>The stream</returns> public Stream GetResponseStream(CacheSettings cacheSettings) { return GetResponseStream(cacheSettings, DEFAULT_TIMEOUT_MS); }
public override Boolean AttachStorage(String myStorageLocation) { lock (this) { if (_FileStream == null) { _StorageLocation = myStorageLocation; var _ImageFileLocation = GetImageFileLocation(myStorageLocation); _WriteQueueLock = new WriteQueueLock(); _FileStream = new FileStream(_ImageFileLocation, FileMode.Open); _ReadQueue = new ReadQueueManager(_WriteQueueLock); _WriteQueue = new WriteQueueManager(_WriteQueueLock); _ReadQueue.SetFileStream(_FileStream); _WriteQueue.SetFileStream(_FileStream); // Configure the ByteCache if (_ByteCacheSettings == null) _ByteCacheSettings = new CacheSettings() { TimerDueTime = TimeSpan.FromSeconds(3), TimerPeriod = TimeSpan.FromSeconds(120), AbsoluteExpirationTimeSpan = TimeSpan.FromSeconds(120), ExpirationType = ExpirationTypes.Absolute }; _ByteCache = new ByteCache("<FileStorage> " + _StorageLocation, _ByteCacheSettings); _WriteQueue.NotificationDispatcher = _NotificationDispatcher; _WriteQueue.OnFlushSucceeded += new FlushSucceededHandler(WriteQueue_OnFlushSucceeded); return true; } return false; } }
/// <summary> /// Begins an asynchronous request using the default timeout /// </summary> /// <param name="useCache">true to cache, otherwise false</param> public void StartRequest(CacheSettings cacheSettings) { StartRequest(cacheSettings, DEFAULT_TIMEOUT_MS); }
public RedisCacheHealthCheck(IOptions <CacheSettings> settings) { _settings = settings.Value; }
public CachingProvider(IOptions <CacheSettings> settingsOptions, IExceptionHandler exceptionHandler) { _settings = settingsOptions.Value; _exceptionHandler = exceptionHandler; }
public TriggerInvalidation(string groupName, CacheSettings settings, string parameterProperty) { KeyBuilder.GroupName = groupName; KeyBuilder.Settings = settings; KeyBuilder.ParameterProperty = parameterProperty; }
private void menuSettingsCache_Click(object sender, EventArgs e) { CacheSettings cs = new CacheSettings(); cs.ShowDialog(); }
/// <summary> /// Provides for defering the execution of the <paramref name="source"/> query to a batch of future queries. /// </summary> /// <typeparam name="T">The type of the elements of <paramref name="source"/>.</typeparam> /// <param name="source">An <see cref="T:System.Linq.IQueryable`1"/> to add to the batch of future queries.</param> /// <param name="duration">The amount of time, in seconds, that a cache entry is to remain in the output cache.</param> /// <returns> /// An instance of <see cref="FutureCount"/> that contains the result of the query. /// </returns> /// <seealso cref="T:CodeSmith.Data.Linq.FutureCount"/> public static IFutureValue <int> FutureCacheCount <T>(this IQueryable <T> source, int duration) { var cacheSettings = new CacheSettings(duration); return(FutureCacheCount(source, cacheSettings)); }
public object Clone() { CacheServerConfig config = new CacheServerConfig(); config.cacheSettings = CacheSettings != null ? (CacheServerConfigSetting)CacheSettings.Clone() : null; config.cacheDeployment = CacheDeployment != null ? (CacheDeployment)CacheDeployment.Clone() : null; config.Name = Name != null ? (string)Name.Clone() : null; config.IsRegistered = this.IsRegistered; config.IsRunning = this.IsRunning; config.licenseIsExpired = this.licenseIsExpired; return(config); }
public ValueTask <CacheEntry <T> > WithRefreshAsync <T>(string cacheKey, Func <ValueTask <CacheEntry <T> > > valueProvider, CacheSettings settings) { if (!HasCacheRefreshCallSiteWrapperExtension) { return(valueProvider()); } else { return(CacheRefreshCallSiteWrapperExtension !.WithRefreshAsync(cacheKey, valueProvider, settings)); } }
public LightweightCache(string name, CacheSettings cacheOptions) { _innerCache = new Data.Caching.Cache <TKey, TValue>(name, cacheOptions.Size); }
/// <summary> /// Synchronously retrieves a response stream for this request /// </summary> /// <param name="useCache">true to use cache, otherwise false</param> /// <returns>The stream</returns> public Stream GetResponseStream(CacheSettings cacheSettings) { return(GetResponseStream(cacheSettings, DEFAULT_TIMEOUT_MS)); }
public MemoryCache(IMemoryCache cache, CacheSettings settings) { _cache = cache; _settings = settings; }
public CommentsRepository(IMemoryCache memoryCache, IOptions <CacheSettings> cacheSettings, IOptions <ConnectionStrings> connectionStrings) { _memoryCache = memoryCache; _connectionStrings = connectionStrings.Value; _cacheSettings = cacheSettings.Value; }
public CachingModule(CacheSettings settings) { _settings = settings ?? new CacheSettings(); }
protected override void SetCacheSettings(ContentReference contentReference, IEnumerable <GetChildrenReferenceResult> children, CacheSettings cacheSettings) { // Make the cache of this content provider depend on the original content cacheSettings.CacheKeys.Add(DataFactoryCache.PageCommonCacheKey(new ContentReference(contentReference.ID))); foreach (var child in children) { cacheSettings.CacheKeys.Add(DataFactoryCache.PageCommonCacheKey(new ContentReference(child.ContentLink.ID))); } }
public CachingModule(IConfiguration configuration) { _settings = configuration.GetSection("CacheSettings").Get <CacheSettings>() ?? new CacheSettings(); }
public DistributedCacheService(IOptions <CacheSettings> cacheSettings) { _cacheSettings = cacheSettings.Value; }
public static void AddCache(this IServiceCollection services, CacheSettings cacheSettings) { services.AddStackExchangeRedisCache(options => options.Configuration = cacheSettings.ConnectionString); services.AddTransient <ICache, Cache>(); }
public Cacheable(String groupName, CacheSettings settings) : this(groupName, settings, string.Empty) { }
/// <summary> /// Initializes a new instance of the <see cref="T:CodeSmith.Data.Linq.FutureValue`1"/> class. /// </summary> /// <param name="query">The query source to use when materializing.</param> /// <param name="loadAction">The action to execute when the query is accessed.</param> /// <param name="cacheSettings">The cache settings.</param> public FutureValue(IQueryable query, Action loadAction, CacheSettings cacheSettings) : base(query, loadAction, cacheSettings) { }
public SettingsPageViewModel( PageManager pageManager, NotificationService toastService, Services.DialogService dialogService, NGSettings ngSettings, RankingSettings rankingSettings, ActivityFeedSettings activityFeedSettings, AppearanceSettings appearanceSettings, CacheSettings cacheSettings ) : base(pageManager) { ToastNotificationService = toastService; NgSettings = ngSettings; RankingSettings = rankingSettings; _HohoemaDialogService = dialogService; NgSettings = ngSettings; RankingSettings = rankingSettings; ActivityFeedSettings = activityFeedSettings; AppearanceSettings = appearanceSettings; CacheSettings = cacheSettings; IsLiveAlertEnabled = ActivityFeedSettings.ToReactivePropertyAsSynchronized(x => x.IsLiveAlertEnabled) .AddTo(_CompositeDisposable); // NG Video Owner User Id NGVideoOwnerUserIdEnable = NgSettings.ToReactivePropertyAsSynchronized(x => x.NGVideoOwnerUserIdEnable); NGVideoOwnerUserIds = NgSettings.NGVideoOwnerUserIds .ToReadOnlyReactiveCollection(); OpenUserPageCommand = new DelegateCommand <UserIdInfo>(userIdInfo => { pageManager.OpenPage(HohoemaPageType.UserInfo, userIdInfo.UserId); }); // NG Keyword on Video Title NGVideoTitleKeywordEnable = NgSettings.ToReactivePropertyAsSynchronized(x => x.NGVideoTitleKeywordEnable); NGVideoTitleKeywords = new ReactiveProperty <string>(); NGVideoTitleKeywordError = NGVideoTitleKeywords .Select(x => { if (x == null) { return(null); } var keywords = x.Split('\r'); var invalidRegex = keywords.FirstOrDefault(keyword => { Regex regex = null; try { regex = new Regex(keyword); } catch { } return(regex == null); }); if (invalidRegex == null) { return(null); } else { return($"Error in \"{invalidRegex}\""); } }) .ToReadOnlyReactiveProperty(); // アピアランス var currentTheme = App.GetTheme(); SelectedApplicationTheme = new ReactiveProperty <string>(currentTheme.ToString(), mode: ReactivePropertyMode.DistinctUntilChanged); SelectedApplicationTheme.Subscribe(x => { var type = (ApplicationTheme)Enum.Parse(typeof(ApplicationTheme), x); App.SetTheme(type); // 一度だけトースト通知 if (!ThemeChanged) { toastService.ShowToast("Hohoemaを再起動するとテーマが適用されます。", ""); } ThemeChanged = true; RaisePropertyChanged(nameof(ThemeChanged)); }); IsTVModeEnable = AppearanceSettings .ToReactivePropertyAsSynchronized(x => x.IsForceTVModeEnable); IsXbox = Services.Helpers.DeviceTypeHelper.IsXbox; IsForceMobileModeEnable = AppearanceSettings .ToReactivePropertyAsSynchronized(x => x.IsForceMobileModeEnable); IsDefaultFullScreen = new ReactiveProperty <bool>(ApplicationView.PreferredLaunchWindowingMode == ApplicationViewWindowingMode.FullScreen); IsDefaultFullScreen.Subscribe(x => { if (x) { ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen; } else { ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto; } }); StartupPageType = AppearanceSettings .ToReactivePropertyAsSynchronized(x => x.StartupPageType); // キャッシュ DefaultCacheQuality = CacheSettings.ToReactivePropertyAsSynchronized(x => x.DefaultCacheQuality); IsAllowDownloadOnMeteredNetwork = CacheSettings.ToReactivePropertyAsSynchronized(x => x.IsAllowDownloadOnMeteredNetwork); DefaultCacheQualityOnMeteredNetwork = CacheSettings.ToReactivePropertyAsSynchronized(x => x.DefaultCacheQualityOnMeteredNetwork); // シェア IsLoginTwitter = new ReactiveProperty <bool>(/*TwitterHelper.IsLoggedIn*/ false); TwitterAccountScreenName = new ReactiveProperty <string>(/*TwitterHelper.TwitterUser?.ScreenName ?? ""*/); // アバウト var version = Windows.ApplicationModel.Package.Current.Id.Version; #if DEBUG VersionText = $"{version.Major}.{version.Minor}.{version.Build} DEBUG"; #else VersionText = $"{version.Major}.{version.Minor}.{version.Build}"; #endif var dispatcher = Window.Current.CoreWindow.Dispatcher; LisenceSummary.Load() .ContinueWith(async prevResult => { await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { var lisenceSummary = prevResult.Result; LisenceItems = lisenceSummary.Items .OrderBy(x => x.Name) .Select(x => new LisenceItemViewModel(x)) .ToList(); RaisePropertyChanged(nameof(LisenceItems)); }); }); IsDebugModeEnabled = new ReactiveProperty <bool>((App.Current as App).IsDebugModeEnabled, mode: ReactivePropertyMode.DistinctUntilChanged); IsDebugModeEnabled.Subscribe(isEnabled => { (App.Current as App).IsDebugModeEnabled = isEnabled; }) .AddTo(_CompositeDisposable); }
public CacheSettingsPageContentViewModel( HohoemaApp hohoemaApp , EditAutoCacheConditionDialogService editDialogService , AcceptCacheUsaseDialogService cacheConfirmDialogService ) : base("キャッシュ", HohoemaSettingsKind.Cache) { _HohoemaApp = hohoemaApp; _CacheSettings = _HohoemaApp.UserSettings.CacheSettings; _EditDialogService = editDialogService; _AcceptCacheUsaseDialogService = cacheConfirmDialogService; IsAutoCacheOnPlayEnable = _CacheSettings.ToReactivePropertyAsSynchronized(x => x.IsAutoCacheOnPlayEnable); IsUserAcceptRegalNotice = _CacheSettings.ToReactivePropertyAsSynchronized(x => x.IsUserAcceptedCache); IsCacheFolderSelectedButNotExist = new ReactiveProperty <bool>(false); ReadCacheAcceptTextCommand = new DelegateCommand(async() => { await cacheConfirmDialogService.ShowAcceptCacheTextDialog(); }); AddAutoCacheConditionCommand = new DelegateCommand(() => { _CacheSettings.CacheOnPlayTagConditions.Add(new TagCondition() { Label = "NewCondition" }); }); AutoCacheConditions = _CacheSettings.CacheOnPlayTagConditions.ToReadOnlyReactiveCollection( x => new AutoCacheConditionViewModel(_CacheSettings, x) ); EditAutoCacheConditionCommnad = new DelegateCommand <AutoCacheConditionViewModel>(async(conditionVM) => { await EditAutoCacheCondition(conditionVM); }); Observable.Merge( IsUserAcceptRegalNotice.ToUnit(), IsAutoCacheOnPlayEnable.ToUnit() ) .Subscribe(async _ => { await _CacheSettings.Save().ConfigureAwait(false); }); CacheFolderStateDescription = new ReactiveProperty <string>(""); CacheSaveFolderPath = new ReactiveProperty <string>(""); OpenCurrentCacheFolderCommand = new DelegateCommand(async() => { await RefreshCacheSaveFolderStatus(); var folder = await _HohoemaApp.GetVideoCacheFolder(); if (folder != null) { await Launcher.LaunchFolderAsync(folder); } }); IsEnableCache = _HohoemaApp.UserSettings .CacheSettings.ToReactivePropertyAsSynchronized(x => x.IsEnableCache); IsEnableCache .Where(x => x) .Where(_ => false == _HohoemaApp.UserSettings.CacheSettings.IsUserAcceptedCache) .Subscribe(async x => { // ユーザーがキャッシュ機能利用に対する承諾を行っていない場合に // 確認のダイアログを表示する var result = await _AcceptCacheUsaseDialogService.ShowConfirmAcceptCacheDialog(); if (result) { _HohoemaApp.UserSettings.CacheSettings.IsUserAcceptedCache = true; await RefreshCacheSaveFolderStatus(); } else { IsEnableCache.Value = false; } }); IsEnableCache.Subscribe(async _ => { await RefreshCacheSaveFolderStatus(); }); ChangeCacheFolderCommand = new DelegateCommand(async() => { if (await _HohoemaApp.ChangeUserDataFolder()) { await RefreshCacheSaveFolderStatus(); } }); }
public static string GetOrderBookKey(this CacheSettings settings, string assetPairId, bool isBuy) { return(string.Format(settings.OrderBooksCacheKeyPattern, assetPairId, isBuy)); }
/// <summary> /// The set cache settings. /// </summary> /// <param name="contentReference"> /// The content reference. /// </param> /// <param name="children"> /// The children. /// </param> /// <param name="cacheSettings"> /// The cache settings. /// </param> protected override void SetCacheSettings( ContentReference contentReference, IEnumerable<ContentReference> children, CacheSettings cacheSettings) { if (ContentReference.IsNullOrEmpty(contentReference) || children == null || cacheSettings == null) { return; } // Make the cache of this content provider depend on the original content cacheSettings.CacheKeys.Add(DataFactoryCache.PageCommonCacheKey(new ContentReference(contentReference.ID))); foreach (ContentReference child in children) { cacheSettings.CacheKeys.Add(DataFactoryCache.PageCommonCacheKey(new ContentReference(child.ID))); } }