tensorflow/core/platform/cloud/ram_file_block_cache.cc
/// Move the block to the front of the LRU list if it isn't already there.
Move the block to the front of the LRU list if it isn't already there.
Move the block to the front of the LRU list if it isn ' t already there .
Status RamFileBlockCache::UpdateLRU(const Key& key,
                                    const std::shared_ptr<Block>& block) {
  mutex_lock lock(mu_);
  if (block->timestamp == 0) {
    return Status::OK();
  }
  if (block->lru_iterator != lru_list_.begin()) {
    lru_list_.erase(block->lru_iterator);
    lru_list_.push_front(key);
    block->lru_iterator = lru_list_.begin();
  }
  if (block->data.size() < block_size_) {
    Key fmax = std::make_pair(key.first, std::numeric_limits<size_t>::max());
    auto fcmp = block_map_.upper_bound(fmax);
    if (fcmp != block_map_.begin() && key < (--fcmp)->first) {
      return errors::Internal("Block cache contents are inconsistent.");
    }
  }
  Trim();
  return Status::OK();
}
Status RamFileBlockCache :: UpdateLRU ( const Key & key , const std :: shared_ptr < Block > & block ) { mutex_lock lock ( mu_ ) ; if ( block -> timestamp == 0 ) { return Status :: OK ( ) ; } if ( block -> lru_iterator != lru_list_ . begin ( ) ) { lru_list_ . erase ( block -> lru_iterator ) ; lru_list_ . push_front ( key ) ; block -> lru_iterator = lru_list_ . begin ( ) ; } if ( block -> data . size ( ) < block_size_ ) { Key fmax = std :: make_pair ( key . first , std :: numeric_limits < size_t > :: max ( ) ) ; auto fcmp = block_map_ . upper_bound ( fmax ) ; if ( fcmp != block_map_ . begin ( ) && key < ( -- fcmp ) -> first ) { return errors :: Internal ( " " ) ; } } Trim ( ) ; return Status :: OK ( ) ; }
Move the block to the front of the LRU list if it isn't already there.
Move the block to the front of the LRU list if it isn ' t already there .
// The block was evicted from another thread. Allow it to remain evicted. // Check for inconsistent state. If there is a block later in the same file // in the cache, and our current block is not block size, this likely means // we have inconsistent state within the cache. Note: it's possible some // incomplete reads may still go undetected.