Skip to content

PostedTransactionCache: add a TTL to every transaction#3023

Closed
NachoSoto wants to merge 1 commit into
mainfrom
transaction-cache-ttl
Closed

PostedTransactionCache: add a TTL to every transaction#3023
NachoSoto wants to merge 1 commit into
mainfrom
transaction-cache-ttl

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

This was suggested in #2914 as a way to prevent the cache from growing forever.

Other changes:

  • Added PostedTransactionCache.unpostedTransactions: this was added in TransactionPoster: avoid posting transactions multiple times #2914, so I put it here to prevent merge conflicts.
  • PostedTransactionCache now verifies that cache interaction doesn't happen in the main thread
  • Added debug log when saving transactions
  • Added debug log when pruning cache
  • Added ClockType tests

This was suggested in #2914 as a way to prevent the cache from growing forever.

### Other changes:
- Added `PostedTransactionCache.unpostedTransactions`: this was added in #2914, so I put it here to prevent merge conflicts.
- `PostedTransactionCache` now verifies that cache interaction doesn't happen in the main thread
- Added debug log when saving transactions
- Added debug log when pruning cache
- Added `ClockType` tests
@NachoSoto NachoSoto requested a review from a team August 16, 2023 17:05
Comment on lines +47 to +48
self.pruneOldTransactions(from: &transactions)
transactions[transaction.transactionIdentifier] = self.clock.now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire modification is done in place so we don't end up with 2 dictionary copies in memory.

expect(self.cache.hasPostedTransaction(transaction2)) == true
}

func testHasPostedTransactionDoesNotTakeDateIntoAccount() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes hasPostedTransaction faster, we only prune when writing.

@NachoSoto

Copy link
Copy Markdown
Contributor Author

Closing this. As shown in #3020 this won't work with that 😢

@NachoSoto NachoSoto closed this Aug 16, 2023
NachoSoto added a commit that referenced this pull request Aug 17, 2023
This is extracted from #3023. That's closed but this is still useful.
@NachoSoto NachoSoto deleted the transaction-cache-ttl branch August 28, 2023 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant