public IChangeToken Watch(string filter) { if (filter.StartsWith("themevars.scss")) { var services = EngineContext.Current.Scope; var theme = services.Resolve <IThemeContext>().WorkingThemeName; var storeId = services.Resolve <IStoreContext>().CurrentStore.Id; var cts = WebCacheInvalidator.GetThemeVarsToken(theme, storeId); return(new CancellationChangeToken(cts.Token)); } else if (filter.StartsWith("moduleimports.scss")) { // TODO: Implement module importer watcher in SassFileProvider } return(null); }
public virtual async Task <ExpandoObject> GetRawVariablesAsync(string themeName, int storeId, bool skipCache = false) { // TODO: (core) "skipCache" somehow replaces ThemeHelper.IsStyleValidationRequest(). Change the callers accordingly. if (skipCache) { // Return uncached fresh data (the variables is not nuked yet) return(await GetRawVariablesCoreAsync(themeName, storeId)); } else { string cacheKey = WebCacheInvalidator.BuildThemeVarsCacheKey(themeName, storeId); return(await _memCache.GetOrCreateAsync(cacheKey, async (entry) => { // Ensure that when this item is expired, any bundle depending on the token is also expired entry.RegisterPostEvictionCallback((key, value, reason, state) => { WebCacheInvalidator.CancelThemeVarsToken(key); }); return await GetRawVariablesCoreAsync(themeName, storeId); })); } }