diff --git a/src/dodb/storage/stacked.cr b/src/dodb/storage/stacked.cr index 6f20256..8a39dfc 100644 --- a/src/dodb/storage/stacked.cr +++ b/src/dodb/storage/stacked.cr @@ -37,7 +37,7 @@ class DODB::Storage::Stacked(V) < DODB::Storage::Cached(V) property stack : FIFO(Int32) # Initializes the `StackedDataBase` with a maximum number of entries in the cache. - def initialize(@directory_name : String, max_entries : UInt32 = 100_000) + def initialize(@directory_name : String, max_entries : UInt32) @stack = FIFO(Int32).new max_entries Dir.mkdir_p data_path Dir.mkdir_p locks_directory diff --git a/src/fifo.cr b/src/fifo.cr index 81b7093..4b060a9 100644 --- a/src/fifo.cr +++ b/src/fifo.cr @@ -30,7 +30,7 @@ class FIFO(V) # NOTE: `#<<(v : V)` is (almost) the only function since it's enough for the intended use, feel free to improve this. # WARNING: implementation is extremely simple (3 lines) and not designed to be highly efficient. def <<(v : V) : V? - @data.select! { |x| v != v } # remove dups + @data.select! { |x| v != x } # remove dups @data.unshift v # push on top of the stack @data.pop if @data.size > @max_entries # remove least recently used entry if `@data` is too big end