lib/sp_store/server/hash_tree_controller.rb
def allocate_cache_entry( target_node, needed_nodes )
    if @num_of_used_entries < @cache.capacity  #use unused cache entries first
       @cache_infos[target_node].cache_entry = @num_of_used_entries
       @num_of_used_entries += 1
       @cache_leaves.add target_node
       @cache_leaves.delete parent(target_node)
       old_parent_entry = 0
    else # cache is full
       victim = choose_victim (@cache_leaves-needed_nodes)
       replace_cache victim, target_node
       old_parent_entry = node_cache_entry parent(victim)
    end
    update_node_access_time target_node
    old_parent_entry
  end
# allocate cache_entry to target node
# should not use the cache entry that caches the node within the {needed_nodes} set
allocate cache_entry to target node
should not use the cache entry that caches the node within the {needed_nodes} set
allocate cache_entry to target node should not use the cache entry that caches the node within the { needed_nodes } set
def allocate_cache_entry( target_node, needed_nodes )
    if @num_of_used_entries < @cache.capacity  
       @cache_infos[target_node].cache_entry = @num_of_used_entries
       @num_of_used_entries += 1
       @cache_leaves.add target_node
       @cache_leaves.delete parent(target_node)
       old_parent_entry = 0
    else 
       victim = choose_victim (@cache_leaves-needed_nodes)
       replace_cache victim, target_node
       old_parent_entry = node_cache_entry parent(victim)
    end
    update_node_access_time target_node
    old_parent_entry
  end
def allocate_cache_entry ( target_node , needed_nodes ) if @num_of_used_entries < @cache . capacity @cache_infos [ target_node ] . cache_entry = @num_of_used_entries @num_of_used_entries += 1 @cache_leaves . add target_node @cache_leaves . delete parent ( target_node ) old_parent_entry = 0 else victim = choose_victim ( @cache_leaves - needed_nodes ) replace_cache victim , target_node old_parent_entry = node_cache_entry parent ( victim ) end update_node_access_time target_node old_parent_entry end
allocate cache_entry to target node
should not use the cache entry that caches the node within the {needed_nodes} set
allocate cache_entry to target node should not use the cache entry that caches the node within the { needed_nodes } set
#use unused cache entries first # cache is full
target_node
needed_nodes