lib/perobs/SpaceTree.rb in perobs-3.0.2 vs lib/perobs/SpaceTree.rb in perobs-4.0.0
- old
+ new
@@ -25,11 +25,11 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
require 'perobs/Log'
require 'perobs/EquiBlobsFile'
-require 'perobs/SpaceTreeNodeCache'
+require 'perobs/PersistentObjectCache'
require 'perobs/SpaceTreeNode'
require 'perobs/FlatFile'
module PEROBS
@@ -49,11 +49,13 @@
# This EquiBlobsFile contains the nodes of the SpaceTree.
@nodes = EquiBlobsFile.new(@dir, 'database_spaces',
SpaceTreeNode::NODE_BYTES, 1)
- @cache = SpaceTreeNodeCache.new(self, 128)
+ # Benchmark runs showed a cache size of 128 to be a good compromise
+ # between read and write performance trade-offs and memory consumption.
+ @cache = PersistentObjectCache.new(128, SpaceTreeNode, self)
end
# Open the SpaceTree file.
def open
@nodes.open
@@ -64,10 +66,10 @@
@root_address = node.node_address
end
# Close the SpaceTree file.
def close
- @cache.flush
+ @cache.flush(true)
@nodes.close
@root_address = nil
@cache.clear
end