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

TTL for empty results in lookup tables #17994

Merged
merged 13 commits into from Mar 13, 2024
Merged

TTL for empty results in lookup tables #17994

merged 13 commits into from Mar 13, 2024

Conversation

patrickmann
Copy link
Contributor

@patrickmann patrickmann commented Jan 19, 2024

Resolves #16466

Description

Adds optional TTL for empty results in lookup table caching. This is not available if ignore null has been checked.

Motivation and Context

If we are caching empty results, then by default they live forever. This is not compatible with data adapters where the value may change over time, specifically DNS. A fixed expiration (expire after write) is not helpful, because that would potentially expire non-null values prematurely. By tuning the TTL for empty results we can avoid requerying the data source excessively, while still becoming aware of changes in values.

How Has This Been Tested?

Simple test scenario:

  • create a CSV file lookup table:
    -- data adapter check interval = 10s
    -- cache: empty TTL = 30s and ignore null = false)
  • query for a non-existent key x: result null
  • update CSV to include x
  • requery before 30s have elapsed: result null
  • requery after 30s: result is the newly saved value from CSV file

Empty TTL overrides the expire after access setting (for null values). Otherwise we would never update a cached null value, that is being requeried very frequently.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@patrickmann patrickmann requested a review from a team January 23, 2024 13:59
@patrickmann patrickmann marked this pull request as ready for review January 23, 2024 13:59
@kodjo-anipah kodjo-anipah self-requested a review March 11, 2024 12:40
Copy link
Contributor

@kodjo-anipah kodjo-anipah left a comment

Choose a reason for hiding this comment

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

LGTM,
Tested with csv.

  1. key does not exist tll empty not configured -> never updates
  2. key does not exist first ttl empty configured, key added later -> updates
  3. ignore empty results -> configuring value for ttl empty is deactivated

@patrickmann patrickmann merged commit e5e37e1 into master Mar 13, 2024
7 checks passed
@patrickmann patrickmann deleted the ttlEmpty branch March 13, 2024 07:19
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.

Configurable lookup table cache TTL for empty values
3 participants