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

File dependency caching #16

Open
francislavoie opened this issue Sep 27, 2016 · 3 comments
Open

File dependency caching #16

francislavoie opened this issue Sep 27, 2016 · 3 comments

Comments

@francislavoie
Copy link

I do like that this lib automatically handles caching, but it's pretty annoying to have to clear the cache every time I want to test changes to my configs. It would be beneficial if this lib checked the last modified time of the files it loads before loading from cache as an option. That can be done using filemtime on the file(s) loaded. For my case, I only have one file to load, so this would be cheap.

Thanks

@m1
Copy link
Owner

m1 commented Sep 28, 2016

Just set cache to false when in development, it'll stop the cache being built. I was thinking about rebuilding the cache module anyway to do similar to what you were saying anyway.

https://github.com/m1/Vars#options

@m1
Copy link
Owner

m1 commented Oct 1, 2016

@francislavoie okay to close this?

@francislavoie
Copy link
Author

francislavoie commented Mar 16, 2017

Sorry I never answered, I still think this is needed. There needs to be a good way to invalidate the cache. You said you were thinking about rebuilding the cache module, so I think it's worth keeping this issue open until you get to that.

I was thinking about writing a PR for this, but right now there's no obvious way to get a list of the files loaded from the cache module. It would need a bit of a rewrite to make that information available, and that's more work than I have time to commit.

Your suggestion for development is fine, but I don't just want this for development, I want it for production too so I don't have to wipe the cache (delete the vars folder) or wait 5 minutes. I also use a long-running job queue service, and if the config is changed I need to reboot those as well (they only read config once at the start) and if the old config is cached and I reboot them, then they'll still have the old config. So I always have to wipe the cache myself every time I make a change.

For now, I'm going to write a manual check ahead of where I load M1\Vars\Vars where I do filemtime against the cache and my config file, if the config is newer I'll unlink the cache file.

Thanks!

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