@@ -86,17 +86,8 @@ impl BillStoreApi for SurrealBillStore {
86
86
identity_node_id : & str ,
87
87
bill : & BitcreditBillResult ,
88
88
) -> 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 ?;
100
91
101
92
// then, put in the new one
102
93
let entity: BitcreditBillResultDb = ( bill, identity_node_id) . into ( ) ;
@@ -1546,24 +1537,19 @@ pub mod tests {
1546
1537
. expect ( "could not save bill to cache" ) ;
1547
1538
1548
1539
// 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
1555
1540
let cached_bill = store
1556
1541
. get_bill_from_cache ( "1234" , "4321" )
1557
1542
. await
1558
1543
. expect ( "could not fetch from cache" ) ;
1559
1544
assert_eq ! ( cached_bill. as_ref( ) . unwrap( ) . id, "1234" . to_string( ) ) ;
1560
1545
1546
+ // removed for other identity now
1561
1547
// get bills from cache
1562
1548
let cached_bills = store
1563
1549
. get_bills_from_cache ( & [ "1234" . to_string ( ) , "4321" . to_string ( ) ] , "1234" )
1564
1550
. await
1565
1551
. expect ( "could not fetch from cache" ) ;
1566
- assert_eq ! ( cached_bills. len( ) , 2 ) ;
1552
+ assert_eq ! ( cached_bills. len( ) , 1 ) ;
1567
1553
1568
1554
// get bills from cache for other identity
1569
1555
let cached_bills = store
0 commit comments