-
Notifications
You must be signed in to change notification settings - Fork 177
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
optimizing CachingParser #9
base: master
Are you sure you want to change the base?
Conversation
Hey @FurcyPin I am currently working in a project that is bases on this lib but I am trying to put things up to date. For example I have a remote url load for the yaml and a scheduled load. Also on the cache issue you mention I have implemented Guava and I am doing differently. I would love to hear feedback from you. |
Hi @mmarmol. The cache issue I mentioned was minor, simply values are cached twice. |
@FurcyPin whole project. I know that the caching is a minor thing. The idea os Guava was to provide better control in case of needed. You believe is a bad idea? My main problem so far with the lib here is that those not look to active. I started a project that depends on User Agent parsing and though it would be a good idea to share it since as needed in a commercial project it will probably get updated frequently. Thanks for getting back. |
@mmarmol Internally, the CachingParser uses a org.apache.commons.collections.map.LRUMap, and the cache size is hardcoded, so I guess that indeed Guava might allow to have a better control on the cache. Here are a few comments about your implementation of the Parser :
Anyway, updating the yaml on the fly would be an awesome feature, great idea! Hope this help! |
@FurcyPin thanks so much for this feedback!!!
It will actually have caching done, if somebody calls parseOS with agent string "A" I will have a cache entry for that OS with key "userAgent:A". The user user calls just parse to get the full client when calling internally parseOS I will hit cache and return that one, them I will add cache for the other two. But I removed the client cache since is a derived from the other 3. Makes sense?
Actually new parsing instance for os, userAgent and device is created on each yaml update. So they aren't used until the others ends. I don't think it will be unstable while updating, it should keep working normally with the current services.
I think is also valid not doing the cleaning cause the cache itself will eventually free itself if proper configured. So I have set it as option boolean to decide if cache should be cleaned on updates.
I need to figure out how to do this, I am not sure if a md5 or something is available to do that check without having to download the file or save the whole content and do a md5. What would recommend?
I have been following this lib for several months and haven seen any detailed follow up on the pull request, and there are a couple great like one for devices that I have added to my lib. I really need things moving faster since it will be used commercially but we want to keep it opensource. If I see movement here we may get back to this one. Thanks, |
About Caching: About Concurrency issue:
For instance you might get a new UserAgent recognized in a yaml update, and your update About checking if the yaml has changed: I understand your need to move fast, keeping your changes open-source is already a great thing, |
@FurcyPin The yaml is check now by md5 before doing the replace. |
Seems good. The only simple solution I see right now would be to modify your I think it is safe to assume that any application using the ua project will either always ask for the triple Just make sure to avoid the bug my commit is fixing. |
@FurcyPin yes, I have included your code. On last version added also 3 parsers at once replacement. I have another fix to release since the MD5 check for the file right now is wrong. I will release it on version 0.3.1 probably today. |
Any update on this? |
not on my side |
https://github.com/mmarmol/uap-java I am using this one for personal projects if you want to try it. |
When using the method CachingParser.parse(), useless caching is done :
The CachingParser.parse() uses a cache, then calls its parent Parser.parse() method, which calls Parser.parseUserAgent(), which is overriden by CachingParser.parseUserAgent() wich uses a second cache.
The same holds for parseOS().