Allow to use a shared cache between multiple instance of DeviceDetector #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Not sure you want this, but we have done this in our fork to match our behavior.
We mainly use this library in a binary on our server that read logs from a message queue and parse them, including device detection using this library.
We have multiple threads running it to parallelize the process of logs parsing, and since this library consume most of the cpu (no blaming here, i totally understand why it's slow, but it's a fact). we use a specific device detector in each thread (so other threads are not blocked by it).
In order to avoid having a specific cache for each thread we added this code, so even if we have multiple instance of device detector they all use the same cache and it avoid consuming too much memory for the same data.
We also added get_size library that allows to correctly guess the size of a cache structure for moka, and then correctly set limit for our cache in terms of memory and not in terms of items