Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransactionIDCache appears unused #94

Open
DMRobertson opened this issue May 2, 2023 · 0 comments
Open

TransactionIDCache appears unused #94

DMRobertson opened this issue May 2, 2023 · 0 comments

Comments

@DMRobertson
Copy link
Contributor

The only construction I can see is

func NewTransactionIDCache() *TransactionIDCache {
c := ttlcache.NewCache()
c.SetTTL(5 * time.Minute) // keep transaction IDs for 5 minutes before forgetting about them
c.SkipTTLExtensionOnHit(true) // we don't care how many times they ask for the item, 5min is the limit.
return &TransactionIDCache{
cache: c,
}
}
which is only used by tests:
func TestTransactionIDCache(t *testing.T) {
alice := "@alice:localhost"
bob := "@bob:localhost"
eventA := "$a:localhost"
eventB := "$b:localhost"
eventC := "$c:localhost"
txn1 := "1"
txn2 := "2"
cache := NewTransactionIDCache()

Presumably it was supposed to be used to cache this query?

func (h *SyncLiveHandler) TransactionIDForEvents(deviceID string, eventIDs []string) (eventIDToTxnID map[string]string) {
eventIDToTxnID, err := h.Storage.TransactionsTable.Select(deviceID, eventIDs)
if err != nil {
logger.Warn().Str("err", err.Error()).Str("device", deviceID).Msg("failed to select txn IDs for events")
}
return
}

We should determin if txn ID queries are heavy enough to need a cache, and then either use the cache or delete the dead code.

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

No branches or pull requests

1 participant