@@ -470,6 +470,9 @@ def update(self, items, reverse_order=False):
470470 key_hashes ,
471471 ).fetchone ()[0 ]
472472
473+ if total_old_size is None :
474+ total_old_size = 0
475+
473476 conn .execute (
474477 "UPDATE kv_index_num_metadata SET num = num + ? WHERE key = ?" ,
475478 (
@@ -554,7 +557,8 @@ def __run_eviction(self, conn):
554557 if self .eviction .max_size_in_mb :
555558 s = time .time ()
556559 current_size_in_mb = conn .execute (
557- "SELECT num FROM kv_index_num_metadata WHERE key = current_size_in_mb"
560+ "SELECT num FROM kv_index_num_metadata WHERE key = ?" ,
561+ ("current_size_in_mb" ,),
558562 ).fetchone ()[0 ]
559563
560564 if current_size_in_mb >= self .eviction .max_size_in_mb :
@@ -570,6 +574,8 @@ def __run_eviction(self, conn):
570574
571575 if number_of_rows_to_evict == 0 :
572576 return
577+
578+ print ('----' , number_of_rows_to_evict , self .eviction .policy , self .eviction .max_size_in_mb , self .eviction .max_number_of_items )
573579
574580 if not self .eviction .max_size_in_mb :
575581 if self .eviction .policy == EvictionCfg .EvictLRU :
@@ -629,10 +635,7 @@ def popitem(self, reverse=True):
629635 def clear (self ):
630636 with self .__connection as conn :
631637 conn .execute ("DELETE FROM kv_index" )
632- conn .execute (
633- "UPDATE kv_index_num_metadata SET num = 0 WHERE key = ?" ,
634- ("current_size_in_mb" ,),
635- )
638+ conn .execute ("UPDATE kv_index_num_metadata SET num = 0 WHERE key = ?" , ("current_size_in_mb" ,))
636639
637640 def create_trigger (
638641 self ,
0 commit comments