Closed croensch closed 6 years ago
What cache would you like to use?
It might be worth waiting for a PSR-n for caching? That way anyone can use any caching back end they want, thus making the library interoperable.
Other caches won't match the read speed of require
ing a PHP file. So i have no preference. I've currently settled with ua-parser for which i have to generate the file only once.
I later found out that the folks at symfony discovered a way to atomically write files: https://github.com/symfony/Filesystem/blob/master/Filesystem.php
Basically they file_put_contents()
to a tempnam()
and then rename()
it. Maybe this trick could be incorporated into browscap-php somehow (e.g. rather as own implementation instead of being a dependency).
PSR-n caching would be cool too.
Is someone working on a PSR-n caching interface?
Yes, it is a WIP over at php-fig/fig-standards#149
Just a note: Creating a temporary file and renaming it, can fail on Windows. In some very rare cases the created file does not yet exists when you try to work with it (e.g. want to rename it).
@asgrim May we close this issue?
@mimmi20 we already replaced with PSR simple cache, right?
Yes, in V4.
Ok great, yes this can be closed. Thanks!
I noticed this library uses a cache file. My experience with file caching in PHP is that simple things like
file_put_contents()
versusrequire()
orfile_get_contents()
often fail in multi-core environments. Speaking a multi-core server with Apache in preforking mode.I've seen it in other libraries for example Zend_Cache_File, breaking our production environment with empty cache files whenever two processes coincidentally collide. That's why i moved everything to php_apc for good.
Now this library does not provide other caching mechanisms, so i'd like to know what measures are taken to keep it running smoothly in a high load multi-core environment.
To demonstrate, run this in the background
while trying to run this
on my CLI i get three results nothing, "Bus error" and a number.