From da38f8f9460957ffd611da2c235666871a66e3db Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Mon, 20 Jan 2014 10:57:59 -0600 Subject: [PATCH] added purge for already saved keys --- index/storage_kvlite.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index/storage_kvlite.go b/index/storage_kvlite.go index 451b8da79..734114a78 100644 --- a/index/storage_kvlite.go +++ b/index/storage_kvlite.go @@ -12,8 +12,9 @@ import ( ) type KVStorage struct { - db *gkvlite.Store - cc *gkvlite.Collection + db *gkvlite.Store + cc *gkvlite.Collection + evic_count int } func NewKVStorage(path string, slice int, db string) (Storage, error) { @@ -122,6 +123,10 @@ func (self *KVStorage) StoreBlock(bitmap_id int64, db string, slice int, chunk_k value := Bytes(block) self.cc.Set(key, value) - + self.evic_count += 1 + if self.evic_count > 10000 { + self.cc.EvictSomeItems() + self.evic_count = 0 + } return nil }