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

Put your HTTP cache into a subdirectory, Thanks. #93

Closed
valeriyo opened this issue Jan 27, 2020 · 5 comments
Closed

Put your HTTP cache into a subdirectory, Thanks. #93

valeriyo opened this issue Jan 27, 2020 · 5 comments
Assignees

Comments

@valeriyo
Copy link

valeriyo commented Jan 27, 2020

Describe the bug
When I look in the /data/data/my.app.id/cache directory - there is a bunch of files along with "journal" -- which refer to launchdarkly services (e.g. https://app.launchdarkly.com/msdk/...). Most applications use this "cache" directory for many things, and an SDK shouldn't crap all over it.

To reproduce
Just run an app with the launchdarkly SDK, then look inside the /data/data/my.app.id/cache directory with Android Studio's Device File Explorer.

Expected behavior
The HTTP cache that launchdarkly creates should go into a subdirectory, named appropriately, to avoid name conflicts.. For example: "com.launchdarkly.http_cache"

SDK version
2.9.1

LaunchDarklyCacheFiles

@gwhelanLD gwhelanLD self-assigned this Jan 28, 2020
@gwhelanLD
Copy link
Contributor

Hi @valeriyo,

These files are created by OkHttp. Other than journal all the file names are generated through hashes that will prevent any name conflicts. Given the extensive use of OkHttp journal should likely be considered reserved by it and there should be no issue with multiple OkHttp instances using the same journal, it should actually reduce the overall overhead on the cache.

Thanks,
@gwhelanLD

@valeriyo
Copy link
Author

valeriyo commented Jan 29, 2020

Please keep your own cache to yourself, and configure its limit to whatever you think is reasonable. There is absolutely no benefit for sharing launchdarkly cache with the rest of the application, only possible conflicts and issues.

In fact, you configure it to:

private static final int MAX_CACHE_SIZE_BYTES = 500_000

and that's fine, as long as the cache is located in a subdirectory:

OkHttpClient.Builder builder = new OkHttpClient.Builder()
     .cache(new Cache(File(cacheDir, "com.launchdarkly.cache"), MAX_CACHE_SIZE_BYTES))

Thank you very much.

@gwhelanLD
Copy link
Contributor

I've filled this issue in our internal issue tracker (ch63444) so we can schedule time to address it.

Thanks,
@gwhelanLD

@valeriyo
Copy link
Author

valeriyo commented Feb 8, 2020

Thank you

@gwhelanLD
Copy link
Contributor

@valeriyo,

The fix for this is out in the 2.12.0 release.

Thanks for your suggestion,
@gwhelanLD

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

2 participants