Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/15/09 17:11:13 (15 years ago)
Author:
msteinbi
Message:

Improved caching (#372)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/CachedDataAdapter.cs

    r1146 r1149  
    141141    protected abstract void FillCache();
    142142
    143     public abstract void SyncWithDb();
     143    protected abstract void SynchronizeWithDb();
    144144
    145145    protected abstract bool PutInCache(ObjT obj);
     
    147147    protected abstract RowT FindCachedById(long id);
    148148
     149    public void SyncWithDb() {
     150      foreach (ICachedDataAdapter parent in this.parentAdapters) {       
     151        parent.SyncWithDb();
     152      }
     153
     154      cacheLock.AcquireReaderLock(Timeout.Infinite);
     155
     156      this.SynchronizeWithDb();
     157
     158      cacheLock.ReleaseReaderLock();
     159    }
     160
    149161    void CachedDataAdapter_OnUpdate(object sender, EventArgs e) {
    150       foreach (ICachedDataAdapter parent in this.parentAdapters) {
    151         parent.SyncWithDb();
    152       }
    153 
    154       cacheLock.AcquireReaderLock(Timeout.Infinite);
    155 
    156162      this.SyncWithDb();
    157 
    158       cacheLock.ReleaseReaderLock();
    159163    }
    160164
     
    162166      if (row == null)
    163167        return false;
    164       else
    165         return FindCachedById((long)row[row.Table.PrimaryKey[0]]) != null;
     168      else {
     169        cacheLock.AcquireReaderLock(Timeout.Infinite);
     170
     171        bool cached = FindCachedById((long)row[row.Table.PrimaryKey[0]]) != null;
     172
     173        cacheLock.ReleaseReaderLock();
     174
     175        return cached;
     176      }
    166177    }
    167178
Note: See TracChangeset for help on using the changeset viewer.