-
Notifications
You must be signed in to change notification settings - Fork 196
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
APCu from a cron job? #264
Comments
Thats the only place the data you are interested in resides. APCu is an in memory cache, connected only via its api to the rest of php. It's persistence means that its tied to whatever server your REST API is on. If you've got a REST API already built, I would assume you've already got rate limiting / authentication /authorization built into that endpoint. Why not add some GET endpoints, that only admins can access, that gives you the stats you want? |
If you are already running PHP-FPM, just use the wonderful https://github.com/hollodotme/fast-cgi-client (available in Composer too). |
The way APCu allocates its memory (using Even if you set the I would recommend you to use something like memcached or redis for your use case. It would be nice if APCu allowed you to specify a backing file instead of only a mask so you could have persistent APCu content between restarts and the possibility to access the content in a CLI script for e.g. cache warming. |
I don't recommend Memcached or Redis for performance reasons. I've got rid of Memcached for this exact reason (using multiple servers), and created a local PHP server to invalidate old keys (or timestamp based), because APC will always be faster that any other distributed system. As long as you use only one server, you must stick with APCu. The good option is to use a fastcgi client to access data from the cron, if it's created by your main process (if it's a fastcgi server, as PHP-FPM is, of course). But I do agree with you that it would be great if we can access it another way, perhaps it's a |
I realize
apc.enable_cli
just makes APCu work from the CLI. It doesn't give you access to the data used by your web server.I have a bunch of usage data I'm tracking with APCu from my REST API (calls per minute, per user limits). Data integrity isn't important. What's most important is having the smallest impact on performance as I collect it (hence APCu), but I want to occasionally dump some of the data to the database on a schedule to graph later. Ideally in a cron job, but the important part is "on a schedule" without risk of triggering DB writes twice.
Is there any sensible way to do this that I'm missing?
I don't like the idea of a running a localhost-only web server, and making a call to a PHP script with curl.
The text was updated successfully, but these errors were encountered: