Skip to content

Conversation

@EvanHahn
Copy link
Contributor

@EvanHahn EvanHahn commented Jan 28, 2026

no ref

This change should have no user impact.

CacheManager.prototype.get is just an alias for _doGet. Let's remove _doGet and just use the public method.

Summary by CodeRabbit

  • Refactor
    • Improved internal cache management mechanisms for enhanced maintainability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

The private _doGet(key, options) method in CacheManager was replaced by a public get(key, options) method that preserves resolution (including JSON parsing) with an {resolve} option and override handling. Constructor binding of _doGet was removed and internal call sites (including getPublic/getAll) now call get(...).

Changes

Cohort / File(s) Summary
CacheManager changes
ghost/core/core/shared/settings-cache/cache-manager.js
Removed private _doGet(key, options) and its constructor binding; added public get(key, options) implementing the same resolution/JSON parsing and {resolve} flag; updated internal call sites (getPublic, getAll, others) to call this.get(...).

Poem

I'm a rabbit in the cache, hopping through keys,
nibbling JSON crumbs with curious ease.
I found a new doorway — get leads the way,
the old _doGet sleeps where shadows play.
Cheers to clearer paths and quicker days! 🐇✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing an unnecessary private method (_doGet) from CacheManager.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-unnecessary-method-from-cache-manager

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ghost/core/core/shared/settings-cache/cache-manager.js (1)

134-149: Guard override mutation when the cache entry is missing.

cacheEntry is mutated before the null check. If settingsOverrides contains a key not present in settingsCache, this will throw. Consider moving the null check earlier (or creating a stub entry) to avoid a runtime crash.

🛠️ Proposed fix (minimal guard)
-        const cacheEntry = this.settingsCache.get(key);
-
-        if (override) {
-            cacheEntry.value = override.value;
-            cacheEntry.is_read_only = true;
-        }
-
-        if (!cacheEntry) {
-            return;
-        }
+        const cacheEntry = this.settingsCache.get(key);
+        if (!cacheEntry) {
+            return;
+        }
+        if (override) {
+            cacheEntry.value = override.value;
+            cacheEntry.is_read_only = true;
+        }

no ref

This change should have no user impact.

`CacheManager.prototype.get` is just an alias for `_doGet`. Let's remove
`_doGet` and just use the public method.
@EvanHahn EvanHahn force-pushed the remove-unnecessary-method-from-cache-manager branch from 3ce24d9 to 8c9bc98 Compare February 3, 2026 22:43
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ghost/core/core/shared/settings-cache/cache-manager.js (1)

140-149: ⚠️ Potential issue | 🟡 Minor

Reorder the null check before override modification to prevent potential TypeError.

Lines 140-149 access cacheEntry.value before checking if cacheEntry is null. If a key exists in settingsOverrides but not in settingsCache, this will throw a TypeError. The null check must come immediately after retrieving the cache entry.

🛡️ Suggested fix: reorder the null check
         const cacheEntry = this.settingsCache.get(key);

+        if (!cacheEntry) {
+            return;
+        }
+
         if (override) {
             cacheEntry.value = override.value;
             cacheEntry.is_read_only = true;
         }
-
-        if (!cacheEntry) {
-            return;
-        }

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.

2 participants