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

Revert "Simplify DCDO Cache Expiration Logic" #54445

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

Hamms
Copy link
Contributor

@Hamms Hamms commented Oct 24, 2023

Reverts #53833; this caused a bunch of TypeError: Nil is not a valid JSON source. errors on staging: https://app.honeybadger.io/projects/3240/faults/101613548

@Hamms Hamms marked this pull request as ready for review October 24, 2023 17:33
@Hamms Hamms merged commit 124e28a into staging Oct 24, 2023
1 of 2 checks passed
@Hamms Hamms deleted the revert-53833-threadless-dcdo-cache branch October 24, 2023 17:34
Hamms added a commit that referenced this pull request Oct 24, 2023
Hamms added a commit that referenced this pull request Oct 25, 2023
* Revert "Revert "Simplify DCDO Cache Expiration Logic (#53833)" (#54445)"

This reverts commit 124e28a.

* Return Early from DCDO Get if No Key Set

In our previous implementation, we'd never attempt to invoke `.get` directly on the datastore for keys that hadn't ever been set; we just used `.all` to collect everything that was set and put in all in the cache, then tried to get values off the cache.

With the new implementation, we will actually check the datastore for values. This means that any key that hasn't had an explicit value set will attempt to load a `nil` value from the datastore, which right now for the JSON-backed and in-memory datastores will also log an error in Honeybadger.

Instead, we simply check for the existence of the key in the datastore before trying to parse it as JSON. Note that this is already how it works for the DynamoDB-backed datastore used in production; see [this comparable line](https://github.com/code-dot-org/code-dot-org/blob/02f7d6ea7a50454b7304ff81024ff211b81bd13d/lib/dynamic_config/adapters/dynamodb_adapter.rb#L22) in that version of the adapter.
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.

None yet

1 participant