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

Settings cache & clean up "ghostGlobals" #166

Merged
merged 2 commits into from
Jun 17, 2013

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Jun 16, 2013

Please see #165

These two commits clean up the concept of globals, making it more explicit that these are settings from the database. The matching change for Casper is sitting in TryGhost/Casper#11

I have also implemented more explicit caching with reloading when a change occurs. This means the frontend will update with a new blog title when changed in the settings without restarting the server.

Would really appreciate a few eyes on this 😄

ghost.updateSettingsCache(result);
return result;
});
} else {

This comment was marked as abuse.

This comment was marked as abuse.

@jgable
Copy link
Contributor

jgable commented Jun 16, 2013

Connect has this Cache class that might be useful for us to use here but I'm not sure how we'd get to it. Doesn't seem like they export it on the connect module.

@ricardobeat
Copy link
Contributor

Wouldn't it be simpler to load the settings on init as it's done, but then only add a hook to the API's edit method that updates ghost.settings directly? Having special cache logic and a different request handler just for this seems like overkill.

@ErisDS
Copy link
Member Author

ErisDS commented Jun 16, 2013

Why would you not use the cache to return for requests to browse/read?

This way settings has a pre-loaded cache layer that we can depend on to only make DB requests when it has to - in my mind that's how a cache should work.

In all likelihood this is a very short-term solution, as I imagine we will implement pretty heavy caching across the whole DB layer, the only reason for doing settings primitively to start with is that the pre-loading is required, and this sort of fell out as a natural solution to the other problems which resulted from that.

@ricardobeat
Copy link
Contributor

We're on the same page re. a general API cache. I just thought it would be good to keep the separation between application-level stuff and the API layer, for simplicity' sake.

- ghost.js - globals/globalConfig has become settings / settingsCache to make it clearer
- app.js - the ghostGlobals local cache is gone, and the use of res.locals has been cleaned up and simplified, although this needs to be properly split into frontend and admin locals (to be finished in TryGhost#124)
- frontend/index.js - doesn't need to be passed globals and nav properties as res.locals does this for us
@ErisDS
Copy link
Member Author

ErisDS commented Jun 17, 2013

You're most probably right. This version fixes the issues for now though & I really want to get 0.1.1 out the door. So I've raised an issue (#173) for implementing a more permanent caching solution and we'll review the separation at that point too.

@ErisDS ErisDS mentioned this pull request Jun 17, 2013
- ghost.js - split the settings loading out of ghost.init, so that we have a function for loading / reloading settings
- api.js - implemented a new requestHandler, the cachedSettingsRequestHandler which handles all aspects of local caching for settings when making requests
- app.js - updated the settings api routes to use the new cached request handler
ErisDS added a commit that referenced this pull request Jun 17, 2013
Settings cache & clean up "ghostGlobals"
@ErisDS ErisDS merged commit d0eace2 into TryGhost:master Jun 17, 2013
morficus pushed a commit to morficus/Ghost that referenced this pull request Sep 4, 2014
Settings cache & clean up "ghostGlobals"
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

3 participants