CS中的缓存类,保证都看的懂
2007-05-06 15:36 Clingingboy 阅读(1571) 评论(3) 编辑 收藏 举报
什么也不说了,谁都看的懂....
/**//// <summary>
/// Summary description for CSCache.
/// </summary>
public class CSCache
{
private CSCache(){}
//>> Based on Factor = 5 default value
public static readonly int DayFactor = TCache.DayFactor;
public static readonly int HourFactor = TCache.HourFactor;
public static readonly int MinuteFactor = TCache.MinuteFactor;
public static readonly double SecondFactor = TCache.SecondFactor;
public static void ReSetFactor(int cacheFactor)
{
TCache.ReSetFactor(cacheFactor);
}
/**//// <summary>
/// Removes all items from the Cache
/// </summary>
public static void Clear()
{
TCache.Clear();
}
public static void RemoveByPattern(string pattern)
{
TCache.RemoveByPattern(pattern);
}
/**//// <summary>
/// Removes the specified key from the cache
/// </summary>
/// <param name="key"></param>
public static void Remove(string key)
{
TCache.Remove(key);
}
/**//// <summary>
/// Insert the current "obj" into the cache.
/// </summary>
/// <param name="key"></param>
/// <param name="obj"></param>
public static void Insert(string key, object obj)
{
TCache.Insert(key, obj, 1);
}
public static void Insert(string key, object obj, CacheDependency dep)
{
TCache.Insert(key, obj, dep);
}
public static void Insert(string key, object obj, int seconds)
{
TCache.Insert(key, obj, seconds);
}
public static void Insert(string key, object obj, int seconds, CacheItemPriority priority)
{
TCache.Insert(key, obj, seconds, priority);
}
public static void Insert(string key, object obj, CacheDependency dep, int seconds)
{
TCache.Insert(key, obj, dep, seconds);
}
public static void Insert(string key, object obj, CacheDependency dep, int seconds, CacheItemPriority priority)
{
TCache.Insert(key,obj,dep,seconds,priority);
}
public static void MicroInsert (string key, object obj, int secondFactor)
{
TCache.MicroInsert(key, obj, secondFactor);
}
/**//// <summary>
/// Insert an item into the cache for the Maximum allowed time
/// </summary>
/// <param name="key"></param>
/// <param name="obj"></param>
public static void Max(string key, object obj)
{
TCache.Max(key, obj);
}
public static void Max(string key, object obj, CacheDependency dep)
{
TCache.Max(key, obj, dep);
}
/**//// <summary>
/// Insert an item into the cache for the Maximum allowed time
/// </summary>
/// <param name="key"></param>
/// <param name="obj"></param>
public static void Permanent(string key, object obj)
{
TCache.Permanent(key, obj);
}
public static void Permanent(string key, object obj, CacheDependency dep)
{
TCache.Permanent(key, obj, dep);
}
public static object Get(string key)
{
return TCache.Get(key);
}
/**//// <summary>
/// Return int of seconds * SecondFactor
/// </summary>
public static int SecondFactorCalculate(int seconds)
{
// Insert method below takes integer seconds, so we have to round any fractional values
return TCache.SecondFactorCalculate(seconds);
}
}
我看这样也行
不过,如果TCache不可以继承的话,而我们又想偷懒的话,以后就不写代码,然后哪别人的代码,然后就像上面这样干...把命名空间改了就好,高效率操作啊:)
/**//// <summary>
/// Summary description for CSCache.
/// </summary>
public class CSCache
{
private CSCache(){}
//>> Based on Factor = 5 default value
public static readonly int DayFactor = TCache.DayFactor;
public static readonly int HourFactor = TCache.HourFactor;
public static readonly int MinuteFactor = TCache.MinuteFactor;
public static readonly double SecondFactor = TCache.SecondFactor;
public static void ReSetFactor(int cacheFactor)
{
TCache.ReSetFactor(cacheFactor);
}
/**//// <summary>
/// Removes all items from the Cache
/// </summary>
public static void Clear()
{
TCache.Clear();
}
public static void RemoveByPattern(string pattern)
{
TCache.RemoveByPattern(pattern);
}
/**//// <summary>
/// Removes the specified key from the cache
/// </summary>
/// <param name="key"></param>
public static void Remove(string key)
{
TCache.Remove(key);
}
/**//// <summary>
/// Insert the current "obj" into the cache.
/// </summary>
/// <param name="key"></param>
/// <param name="obj"></param>
public static void Insert(string key, object obj)
{
TCache.Insert(key, obj, 1);
}
public static void Insert(string key, object obj, CacheDependency dep)
{
TCache.Insert(key, obj, dep);
}
public static void Insert(string key, object obj, int seconds)
{
TCache.Insert(key, obj, seconds);
}
public static void Insert(string key, object obj, int seconds, CacheItemPriority priority)
{
TCache.Insert(key, obj, seconds, priority);
}
public static void Insert(string key, object obj, CacheDependency dep, int seconds)
{
TCache.Insert(key, obj, dep, seconds);
}
public static void Insert(string key, object obj, CacheDependency dep, int seconds, CacheItemPriority priority)
{
TCache.Insert(key,obj,dep,seconds,priority);
}
public static void MicroInsert (string key, object obj, int secondFactor)
{
TCache.MicroInsert(key, obj, secondFactor);
}
/**//// <summary>
/// Insert an item into the cache for the Maximum allowed time
/// </summary>
/// <param name="key"></param>
/// <param name="obj"></param>
public static void Max(string key, object obj)
{
TCache.Max(key, obj);
}
public static void Max(string key, object obj, CacheDependency dep)
{
TCache.Max(key, obj, dep);
}
/**//// <summary>
/// Insert an item into the cache for the Maximum allowed time
/// </summary>
/// <param name="key"></param>
/// <param name="obj"></param>
public static void Permanent(string key, object obj)
{
TCache.Permanent(key, obj);
}
public static void Permanent(string key, object obj, CacheDependency dep)
{
TCache.Permanent(key, obj, dep);
}
public static object Get(string key)
{
return TCache.Get(key);
}
/**//// <summary>
/// Return int of seconds * SecondFactor
/// </summary>
public static int SecondFactorCalculate(int seconds)
{
// Insert method below takes integer seconds, so we have to round any fractional values
return TCache.SecondFactorCalculate(seconds);
}
}
我看这样也行
public class CSCache:TCache
{
}
{
}
不过,如果TCache不可以继承的话,而我们又想偷懒的话,以后就不写代码,然后哪别人的代码,然后就像上面这样干...把命名空间改了就好,高效率操作啊:)