Esempio n. 1
0
 /// <summary>
 /// Adds a <see cref="DataObject"/> on the cache for the given row/column
 /// of the table.
 /// </summary>
 /// <param name="tableKey"></param>
 /// <param name="row"></param>
 /// <param name="column"></param>
 /// <param name="cell"></param>
 /// <remarks>
 /// Ignores any cells that are larger than the maximum size.
 /// </remarks>
 public void Set(int tableKey, int row, int column, DataObject cell)
 {
     lock (this) {
         int memoryUse = AmountMemory(cell);
         if (memoryUse <= maxCellSize)
         {
             // Generate the key
             var key = new DCCacheKey(tableKey, (short)column, row);
             // If there is an existing object here, remove it from the cache and
             // update the current_cache_size.
             var removedCell = (DataObject)cache.Remove(key);
             if (removedCell != null)
             {
                 currentCacheSize -= AmountMemory(removedCell);
             }
             // Put the new entry in the cache
             cache.Set(key, cell);
             currentCacheSize += memoryUse;
         }
         else
         {
             // If the object is larger than the minimum object size that can be
             // cached, remove any existing entry (possibly smaller) from the cache.
             Remove(tableKey, row, column);
         }
     }
 }
Esempio n. 2
0
            public override bool Equals(Object ob)
            {
                DCCacheKey destKey = (DCCacheKey)ob;

                return(row == destKey.row &&
                       column == destKey.column &&
                       tableId == destKey.tableId);
            }
Esempio n. 3
0
 /// <summary>
 /// Adds a <see cref="DataObject"/> on the cache for the given row/column 
 /// of the table.
 /// </summary>
 /// <param name="tableKey"></param>
 /// <param name="row"></param>
 /// <param name="column"></param>
 /// <param name="cell"></param>
 /// <remarks>
 /// Ignores any cells that are larger than the maximum size.
 /// </remarks>
 public void Set(int tableKey, int row, int column, DataObject cell)
 {
     lock (this) {
         int memoryUse = AmountMemory(cell);
         if (memoryUse <= maxCellSize) {
             // Generate the key
             var key = new DCCacheKey(tableKey, (short)column, row);
             // If there is an existing object here, remove it from the cache and
             // update the current_cache_size.
             var removedCell = (DataObject)cache.Remove(key);
             if (removedCell != null) {
                 currentCacheSize -= AmountMemory(removedCell);
             }
             // Put the new entry in the cache
             cache.Set(key, cell);
             currentCacheSize += memoryUse;
         } else {
             // If the object is larger than the minimum object size that can be
             // cached, remove any existing entry (possibly smaller) from the cache.
             Remove(tableKey, row, column);
         }
     }
 }