Exemplo n.º 1
0
        /// <summary>
        /// Updates the home page item in the cache.
        /// </summary>
        /// <param name="item">The updated homepage item.</param>
        public void UpdateHomePage(PageViewModel item)
        {
            if (!_applicationSettings.UseObjectCache)
            {
                return;
            }

            _cache.Remove(CacheKeys.HomepageKey());
            _cache.Add(CacheKeys.HomepageKey(), item, new CacheItemPolicy());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves the home page item from the cache, or null if it doesn't exist.
        /// </summary>
        /// <returns>The cached <see cref="PageViewModel"/> for the homepage; or null if it doesn't exist.</returns>
        public PageViewModel GetHomePage()
        {
            if (!_applicationSettings.UseObjectCache)
            {
                return(null);
            }

            Log("Get latest homepage");

            return(_cache.Get(CacheKeys.HomepageKey()) as PageViewModel);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Removes the home page item from the cache if it exists.
        /// </summary>
        public void RemoveHomePage()
        {
            if (!_applicationSettings.UseObjectCache)
            {
                return;
            }

            _cache.Remove(CacheKeys.HomepageKey());

            Log("Removed homepage from cache", CacheKeys.HomepageKey());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Removes the page item from the cache if it exists.
        /// </summary>
        /// <param name="id">The id of the page.</param>
        /// <param name="version">The page content version.</param>
        public void Remove(int id, int version)
        {
            if (!_applicationSettings.UseObjectCache)
            {
                return;
            }

            string key = CacheKeys.PageViewModelKey(id, version);

            _cache.Remove(key);

            Log("Removed key '{0}' from cache", key);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Retrieves the page item for a specific version of the page from the cache, or null if it doesn't exist.
        /// </summary>
        /// <param name="id">The id of the page </param>
        /// <param name="version">The version of the page.</param>
        /// <returns>The cached <see cref="PageViewModel"/>; or null if it doesn't exist.</returns>
        public PageViewModel Get(int id, int version)
        {
            if (!_applicationSettings.UseObjectCache)
            {
                return(null);
            }

            string key = CacheKeys.PageViewModelKey(id, version);

            Log("Get key {0} in cache [Id={1}, Version{2}]", key, id, version);

            return(_cache.Get(key) as PageViewModel);
        }
Exemplo n.º 6
0
        // <summary>
        /// Adds an item to the cache.
        /// </summary>
        /// <param name="id">The page's Id.</param>
        /// <param name="version">The pages content's version.</param>
        /// <param name="item">The page.</param>
        public void Add(int id, int version, PageViewModel item)
        {
            if (!_applicationSettings.UseObjectCache)
            {
                return;
            }

            if (!item.IsCacheable)
            {
                return;
            }

            string key = CacheKeys.PageViewModelKey(id, version);

            _cache.Add(key, item, new CacheItemPolicy());

            Log("Added key {0} to cache [Id={1}, Version{2}]", key, id, version);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Gets the plugin settings.
 /// </summary>
 /// <param name="plugin">The text plugin.</param>
 /// <returns>
 /// Returns the <see cref="Settings" /> or null if the plugin is not in the cache.
 /// </returns>
 public PluginSettings GetPluginSettings(TextPlugin plugin)
 {
     return(_cache.Get(CacheKeys.PluginSettingsKey(plugin)) as PluginSettings);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Retrieves the admin menu HTML from the cache, or null if it doesn't exist.
 /// </summary>
 /// <returns>The cache HTML for the admin menu.</returns>
 public string GetAdminMenu()
 {
     return(_cache.Get(CacheKeys.AdminMenuKey()) as string);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Retrieves the navigation menu HTML for logged in users from the cache, or null if it doesn't exist.
 /// </summary>
 /// <returns>The cache HTML for the menu.</returns>
 public string GetLoggedInMenu()
 {
     return(_cache.Get(CacheKeys.LoggedInMenuKey()) as string);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Adds the admin menu HTML to the cache.
 /// </summary>
 /// <param name="html">The menu's HTML.</param>
 public void AddAdminMenu(string html)
 {
     _cache.Add(CacheKeys.AdminMenuKey(), html, new CacheItemPolicy());
 }
Exemplo n.º 11
0
 /// <summary>
 /// Removes all cached HTML for the navigation menus from the cache.
 /// </summary>
 public void RemoveMenuCacheItems()
 {
     _cache.Remove(CacheKeys.MenuKey());
     _cache.Remove(CacheKeys.LoggedInMenuKey());
     _cache.Remove(CacheKeys.AdminMenuKey());
 }
Exemplo n.º 12
0
 /// <summary>
 /// Removes the settings for given plugin from the cache.
 /// </summary>
 /// <param name="plugin">The plugin to remove the cached settings for.</param>
 public void RemovePluginSettings(TextPlugin plugin)
 {
     _cache.Remove(CacheKeys.PluginSettingsKey(plugin));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Updates the plugin settings.
 /// </summary>
 /// <param name="plugin">The text plugin.</param>
 public void UpdatePluginSettings(TextPlugin plugin)
 {
     _cache.Remove(CacheKeys.PluginSettingsKey(plugin));
     _cache.Add(CacheKeys.PluginSettingsKey(plugin), plugin.Settings, new CacheItemPolicy());
 }