Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1029


Ignore:
Timestamp:
12/18/08 15:33:04 (15 years ago)
Author:
msteinbi
Message:

Fixed caching (#372)

Location:
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess
Files:
2 edited

Legend:

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

    r1026 r1029  
    3939      new CacheT();
    4040
    41     protected IDictionary<RowT, DataTable> parentTable =
    42       new Dictionary<RowT, DataTable>();
     41    protected IDictionary<long, DataTable> dataTable =
     42      new Dictionary<long, DataTable>();
    4343
    4444    protected ICollection<ICachedDataAdapter> parentAdapters =
     
    131131    }
    132132
    133     protected virtual void RemoveRowFromCache(RowT row) {
    134       if (parentTable.ContainsKey(row)) {
    135         parentTable[row].Rows.Add(row);
    136         parentTable.Remove(row);
    137       }
    138      
     133    protected virtual void RemoveRowFromCache(RowT row) {     
    139134      cache.Rows.Remove(row);
    140135    }
    141136
    142137    protected virtual bool IsCached(RowT row) {
    143       return cache.Contains<RowT>(row);
     138      if (row == null)
     139        return false;
     140     else
     141        return FindCachedById((long)row[row.Table.PrimaryKey[0]]) != null;
    144142    }
    145143
     
    173171        }
    174172
     173        obj.Id = (long)row[row.Table.PrimaryKey[0]];
     174
    175175        Convert(obj, row);
    176176
     177        if (!IsCached(row))
     178          UpdateRow(row);
     179       
    177180        if (IsCached(row) &&
    178181            !PutInCache(obj)) {
    179182          //remove from cache
     183          dataTable[obj.Id].ImportRow(row);
     184          dataTable.Remove(obj.Id);
     185
     186          UpdateRow(row);
    180187          RemoveRowFromCache(row);
    181           UpdateRow(row);
    182188        } else if (!IsCached(row) &&
    183189          PutInCache(obj)) {
    184190          //add to cache
    185           if (row.Table != null) {
    186             parentTable[row] = row.Table;
    187             row.Table.Rows.Remove(row);
    188           }
    189           cache.Rows.Add(row);
     191          cache.ImportRow(row);
     192
     193          dataTable[obj.Id] = row.Table;
     194          row.Table.Rows.Remove(row);
    190195        }
    191 
    192         obj.Id = (long)row[row.Table.PrimaryKey[0]];
    193 
    194         if (!IsCached(row))
    195           UpdateRow(row);
    196196      }
    197197    }
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/JobAdapter.cs

    r1021 r1029  
    156156    }
    157157
    158     public override void SyncWithDb() {
     158    public override void SyncWithDb() { 
    159159      this.adapter.Update(this.cache);
    160160    }
     
    162162    protected override bool PutInCache(Job job) {
    163163      return job != null
    164         && job.State != State.offline
    165         && job.State != State.nullState;
     164        && (job.State == State.calculating
     165            || job.State == State.idle);
    166166    }
    167167
Note: See TracChangeset for help on using the changeset viewer.