nmondal / cowj

[C]onfiguration [O]nly [Web] on [J]VM
Apache License 2.0
16 stars 11 forks source link

Cache with data having expiry time should be implemented with Expiry Map #124

Closed nmondal closed 1 month ago

nmondal commented 2 months ago

Something like the token cache for Auth. Of course JDBC connections are already implemented like this.

nmondal commented 1 month ago

After much deliberation, it is pointless. In fact it has negative impact. Consider the following.

A token got expired. Great. Now cache has expired token and all call using that token would fail, because of expiry. So it fails fast.

Now suppose we remove it. We do not know whether the data store would have it, if it does - in any case we need to connect to the data store to actually fetch the stuff - and still fail because of token not found or token expiry. So we fail slow.

Therefore, this is a bad idea. The current behavior is good enough.