using System;
using System.Collections.Generic;
using System.Text;
using ScrewTurn.Wiki.PluginFramework;
namespace ScrewTurn.Wiki {
///
/// Manages data cache.
///
public static class Cache {
///
/// Gets the cache provider.
///
public static ICacheProviderV30 Provider {
get { return Collectors.CacheProviderCollector.GetProvider(Settings.DefaultCacheProvider); }
}
///
/// Gets or sets the number of users online.
///
public static int OnlineUsers {
get { return Provider.OnlineUsers; }
set { Provider.OnlineUsers = value; }
}
///
/// Clears the pages cache.
///
public static void ClearPageCache() {
Provider.ClearPageContentCache();
}
///
/// Clears the pseudo cache.
///
public static void ClearPseudoCache() {
Provider.ClearPseudoCache();
}
///
/// Gets a cached .
///
/// The page to get the content of.
/// The page content, or null.
public static PageContent GetPageContent(PageInfo page) {
if(page == null) return null;
return Provider.GetPageContent(page);
}
///
/// Gets a cached formatted page content.
///
/// The page to get the formatted content of.
/// The formatted page content, or null.
public static string GetFormattedPageContent(PageInfo page) {
if(page == null) return null;
return Provider.GetFormattedPageContent(page);
}
///
/// Sets the page content in cache.
///
/// The page to set the content of.
/// The content.
public static void SetPageContent(PageInfo page, PageContent content) {
Provider.SetPageContent(page, content);
if(Provider.PageCacheUsage > Settings.CacheSize) {
Provider.CutCache(Settings.CacheCutSize);
}
}
///
/// Sets the formatted page content in cache.
///
/// The page to set the content of.
/// The content.
public static void SetFormattedPageContent(PageInfo page, string content) {
Provider.SetFormattedPageContent(page, content);
}
///
/// Removes a page from the cache.
///
/// The page to remove.
public static void RemovePage(PageInfo page) {
Provider.RemovePage(page);
}
///
/// Gets a pseudo cache item value.
///
/// The name of the item to get the value of.
/// The value of the item, or null.
public static string GetPseudoCacheValue(string name) {
return Provider.GetPseudoCacheValue(name);
}
///
/// Sets a pseudo cache item value.
///
/// The name of the item to set the value of.
/// The value of the item.
public static void SetPseudoCacheValue(string name, string value) {
Provider.SetPseudoCacheValue(name, value);
}
///
/// Gets the number of pages currently in the page cache.
///
public static int PageCacheUsage {
get { return Provider.PageCacheUsage; }
}
///
/// Gets the number of formatted pages currently in the page cache.
///
public static int FormattedPageCacheUsage {
get { return Provider.FormatterPageCacheUsage; }
}
}
}