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

Remove CacheMap#containsKey before #get #146

Commits on Apr 29, 2024

  1. Remove CacheMap#containsKey before #get

    Currently, when accessing values from the `DataLoader`'s `CacheMap`, we
    first check `#containsKey` before invoking `#get`. This is problematic
    for two reasons:
    
     - the underlying cache's metrics are skewed (it will have a 100% hit
       rate).
     - if the cache has an automatic expiration policy, it is possible a
       value will expire between the `containsKey` and `get` invocations
       leading to an incorrect result.
    
    To ameliorate this, we always invoke `#get` and check if it is `null` to
    deterine whether the key is present. We wrap the invocation in a
    `try`/`catch` as the `#get` method is allowed to through per its
    documentation.
    AlexandreCarlton committed Apr 29, 2024
    Configuration menu
    Copy the full SHA
    12a73d3 View commit details
    Browse the repository at this point in the history