コード例 #1
0
 /// <summary>
 /// Delete object from Cache
 /// </summary>
 /// <param name="key">Key of the object</param>
 /// <param name="Id">Object Id if available then key will be key plus Id</param>
 protected void DeleteFromCache(string key, int Id)
 {
     if (Id > 0)
     {
         CachedData.Remove(key + "-" + Id);
     }
     else
     {
         CachedData.Remove(key);
     }
 }
コード例 #2
0
        protected void Decache()
        {
            PropertyInfo p = this.GetType().GetProperty("ID");

            if (p == null)
            {
                throw new InvalidOperationException("Can't use this version of Cache() with no public ID property");
            }
            int val = Convert.ToInt32(p.GetValue(this, null));

            if (val <= 0)
            {
                throw new InvalidOperationException("Can't decache Business objects that have not been persisted to the store");
            }
            string key = this.GetType().ToString() + Convert.ToString(val);

            CachedData.Remove(key);
        }