@@ -86,17 +86,8 @@ impl BillStoreApi for SurrealBillStore {
8686 identity_node_id : & str ,
8787 bill : & BitcreditBillResult ,
8888 ) -> Result < ( ) > {
89- // first, delete existing cache entry
90- let mut bindings = Bindings :: default ( ) ;
91- bindings. add ( DB_TABLE , Self :: CACHE_TABLE ) ?;
92- bindings. add ( DB_BILL_ID , id. to_owned ( ) ) ?;
93- bindings. add ( DB_IDENTITY_NODE_ID , identity_node_id. to_owned ( ) ) ?;
94- self . db
95- . query_check (
96- "DELETE FROM type::table($table) WHERE bill_id = $bill_id AND identity_node_id = $identity_node_id" ,
97- bindings,
98- )
99- . await ?;
89+ // first, delete existing cache entries for bill
90+ self . invalidate_bill_in_cache ( id) . await ?;
10091
10192 // then, put in the new one
10293 let entity: BitcreditBillResultDb = ( bill, identity_node_id) . into ( ) ;
@@ -1546,24 +1537,19 @@ pub mod tests {
15461537 . expect ( "could not save bill to cache" ) ;
15471538
15481539 // get bill from cache
1549- let cached_bill = store
1550- . get_bill_from_cache ( "1234" , "1234" )
1551- . await
1552- . expect ( "could not fetch from cache" ) ;
1553- assert_eq ! ( cached_bill. as_ref( ) . unwrap( ) . id, "1234" . to_string( ) ) ;
1554- // get bill from cache for other identity
15551540 let cached_bill = store
15561541 . get_bill_from_cache ( "1234" , "4321" )
15571542 . await
15581543 . expect ( "could not fetch from cache" ) ;
15591544 assert_eq ! ( cached_bill. as_ref( ) . unwrap( ) . id, "1234" . to_string( ) ) ;
15601545
1546+ // removed for other identity now
15611547 // get bills from cache
15621548 let cached_bills = store
15631549 . get_bills_from_cache ( & [ "1234" . to_string ( ) , "4321" . to_string ( ) ] , "1234" )
15641550 . await
15651551 . expect ( "could not fetch from cache" ) ;
1566- assert_eq ! ( cached_bills. len( ) , 2 ) ;
1552+ assert_eq ! ( cached_bills. len( ) , 1 ) ;
15671553
15681554 // get bills from cache for other identity
15691555 let cached_bills = store
0 commit comments