holiman / billy

Very simple datastore
BSD 3-Clause "New" or "Revised" License
50 stars 7 forks source link

db: add a method to retrieve the size of an entry #16

Closed karalabe closed 1 year ago

karalabe commented 1 year ago

This PR adds a new method to a billy.Database (Size) to retrieve the slot size belonging to an entry.

The purpose is if we want to evict multiple smaller items in favor of a larger one in a calling application, then we need to know how many(and which ones) to evict after inserting a new item. Without this method, the calling app would need to replicate shelf size tracking and other billy internals. With this method we can just maintain the size of items in the memory index and pick and chose from there without caring how they are managed by billy.

codecov[bot] commented 1 year ago

Codecov Report

Merging #16 (9cbb28c) into main (4c8dcfa) will increase coverage by 0.09%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #16      +/-   ##
==========================================
+ Coverage   89.87%   89.96%   +0.09%     
==========================================
  Files           2        2              
  Lines         316      319       +3     
==========================================
+ Hits          284      287       +3     
  Misses         17       17              
  Partials       15       15