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

Cache size #59

Open
ghost opened this issue Mar 13, 2014 · 3 comments
Open

Cache size #59

ghost opened this issue Mar 13, 2014 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 13, 2014

The size of browscap.ini has more than doubled in the last few months. Using v5024, the corresponding php cache file needs about 20M of RAM. We are using a stripped down version of that file in our WordPress plugin, wp SlimStat.

I was wondering if there was a way to split the cache into multiple files, and then loop through them to load only a subset of agents/browsers at a time.

Would you be able to explain the structure of _browsers and _patterns and how they work together to see if we can split them correctly?

@mimmi20
Copy link

mimmi20 commented Mar 26, 2014

There are 4 arrays needed.

  1. _pattern: it holds the detection rules from the browscap file, but quoted to be able to use them with preg_match, the key in this array is the regex, the value is the key in the _browsers array
  2. _browsers: it holds the values from the browscap file, the property names are replaced with their keys from the _properties array, the property value of the parent property is replaced with their key of the _useragents array
  3. _properties: it holds the properties from the browscap file
  4. _useragents: it holds the values (names) of the parent property

I hope I explaned it right.

Could you tell what kind of browscap file you use (lite, normal or full) ?

@ghost
Copy link
Author

ghost commented Mar 26, 2014

What we ended up doing in WP SlimStat [ https://github.com/getusedtoit/wp-slimstat/tree/master/databases ] is to split the initial ini file into 5 chunks, and then run phpbrowscap on each of them to create the corresponding cache.php. Then we simply loop through the files until we find a match. Memory usage went from 20M to 2M!

@mimmi20
Copy link

mimmi20 commented Mar 26, 2014

If you like, create a feature request on https://github.com/browscap/browscap to let you create these splitted files. Then dont need to do this after each update.

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

1 participant