⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cache.cs

📁 通过数据库结构自动 生成三层结构代码,相当不错的一款软件
💻 CS
字号:
namespace LTP.Utility
{
    using System;
    using System.Collections;
    using System.Runtime.Remoting.Messaging;

    public class Cache
    {
        protected Hashtable _Cache = new Hashtable();
        protected object _LockObj = new object();

        public virtual void Clear()
        {
            lock (this._Cache.SyncRoot)
            {
                this._Cache.Clear();
            }
        }

        public virtual void DelObject(object key)
        {
            lock (this._Cache.SyncRoot)
            {
                this._Cache.Remove(key);
            }
        }

        public virtual object GetObject(object key)
        {
            if (this._Cache.ContainsKey(key))
            {
                return this._Cache[key];
            }
            return null;
        }

        private void Results(IAsyncResult ar)
        {
            ((EventSaveCache) ((AsyncResult) ar).AsyncDelegate).EndInvoke(ar);
        }

        public void SaveCache(object key, object value)
        {
            new EventSaveCache(this.SetCache).BeginInvoke(key, value, new AsyncCallback(this.Results), null);
        }

        protected virtual void SetCache(object key, object value)
        {
            lock (this._LockObj)
            {
                if (!this._Cache.ContainsKey(key))
                {
                    this._Cache.Add(key, value);
                }
            }
        }

        public int Count
        {
            get
            {
                return this._Cache.Count;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -