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

Does lein-ring have a hook for re-initialization? #188

Open
AndyKriger opened this issue Jun 26, 2017 · 1 comment
Open

Does lein-ring have a hook for re-initialization? #188

AndyKriger opened this issue Jun 26, 2017 · 1 comment

Comments

@AndyKriger
Copy link

I have a small application that loads a file of data for caching in an atom. Right now the way that happens is (def cache (atom {})) and (defn init [] ;; reset! the atom from a file). I do it that way so that the file reading only happens when the server is run.

I notice that when I change the Clojure file that is my web app, the atom is reset to it's initial value, rather than the value it is set to by the init function. This makes sense since init is only called on server startup.

Is there a hook that can be called when the file is reloaded that could be used to re-initialize the cache?

Alternatively, is there a more recommended way to do this kind of global caching? While I understand that global state usually is a bad idea, in this case, it makes a lot of sense because this is a small amount of static data that only needs to be loaded once by the server and can be kept in memory for responses to requests.

@MichaelBlume
Copy link
Collaborator

MichaelBlume commented Jun 28, 2017 via email

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

No branches or pull requests

2 participants