Skip to content

Added option for json-file repo #226

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

Merged
merged 7 commits into from
Sep 29, 2020
Merged

Added option for json-file repo #226

merged 7 commits into from
Sep 29, 2020

Conversation

renefloor
Copy link
Contributor

@renefloor renefloor commented Sep 23, 2020

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

Feature

⤵️ What is the current behavior?

Currently only sqflite is supported out of the box. This doesn't work on all platforms.

🆕 What is the new behavior (if this is a feature change)?

Added a simple json-file provider that stores the objects in memory and caches the info in a json based file.
This works on all platforms that are supported by path_provider.

💥 Does this PR introduce a breaking change?

No, it is only made the default on platforms that were not supported yet.

🐛 Recommendations for testing

Test still need to be written.

📝 Links to relevant issues/docs

Fixes #224
Fixes #222
Fixes #197

🤔 Checklist before submitting

  • All projects build
  • Follows style guide lines (code style guide)
  • Relevant documentation was updated
  • Rebased onto current develop

@renefloor renefloor mentioned this pull request Sep 23, 2020
3 tasks
@escamoteur
Copy link

if it stores the objects in memory, isn't that a problem with image data like map tiles?

@renefloor
Copy link
Contributor Author

I have to run some memory tests for comparison, but it only stores some meta info. I can imagine that the sqlite connection uses more memory for relatively small amounts of objects. The amount of objects should never get into the hundreds as that would be much for the cache anyway.

@codecov
Copy link

codecov bot commented Sep 23, 2020

Codecov Report

Merging #226 into develop will increase coverage by 1.95%.
The diff coverage is 80.80%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #226      +/-   ##
===========================================
+ Coverage    73.26%   75.22%   +1.95%     
===========================================
  Files           17       18       +1     
  Lines          475      565      +90     
===========================================
+ Hits           348      425      +77     
- Misses         127      140      +13     
Impacted Files Coverage Δ
flutter_cache_manager/lib/src/cache_manager.dart 87.50% <ø> (ø)
...ter_cache_manager/lib/src/compat/file_fetcher.dart 90.00% <ø> (ø)
...utter_cache_manager/lib/src/config/_config_io.dart 12.50% <0.00%> (-12.50%) ⬇️
...lutter_cache_manager/lib/src/result/file_info.dart 100.00% <ø> (ø)
...cache_info_repositories/cache_object_provider.dart 0.00% <0.00%> (ø)
...info_repositories/non_storing_object_provider.dart 0.00% <0.00%> (ø)
...er/lib/src/storage/file_system/file_system_io.dart 0.00% <ø> (ø)
..._info_repositories/json_cache_info_repository.dart 91.46% <91.46%> (ø)
...er_cache_manager/lib/src/storage/cache_object.dart 93.93% <100.00%> (+0.39%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fbc82be...9933ac1. Read the comment docs.

@hpoul
Copy link
Contributor

hpoul commented Sep 23, 2020

if it stores the objects in memory, isn't that a problem with image data like map tiles?

it is only storing the metadata in memory, not the binary files as far as i understand it, You'd have to cache a lot of objects before you reach the size of the sqlite.so probably 😅️

@escamoteur
Copy link

This here was then a bit missleading:

that stores the objects in memory and caches the info in a json based file.

As a cache is just a map<id,image> there are no queries necessary so I see no real benefit of using Sqlite.
What are you doing if you get too many entries?

@renefloor
Copy link
Contributor Author

Sorry, the naming can be better indeed. (It is already improving though).

The info on a cached files is called a CacheObject. This include info for example on the eTag, the fileName, when it is last used: https://github.com/Baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/lib/src/storage/cache_object.dart
This is all that is stored in memory.

When the cache is used it also checks how many files there are and when the last time was that the files were used.
Files that haven't been used for some time or that are over capacity are removed continuously by the store: https://github.com/Baseflow/flutter_cache_manager/blob/develop/flutter_cache_manager/lib/src/cache_store.dart#L125

@escamoteur
Copy link

Sounds good!

@renefloor renefloor marked this pull request as ready for review September 28, 2020 19:46
@renefloor
Copy link
Contributor Author

Verified it works on Linux and Windows.

@renefloor renefloor merged commit f3a4a32 into develop Sep 29, 2020
@renefloor renefloor deleted the feature/json-repo branch September 29, 2020 07:17
@fmatosqg
Copy link

Very happy to see this.
Pls advise what will be the release version containing this. I couldn't find a release notes file in this repo.

@renefloor
Copy link
Contributor Author

I expect to release it later today as version 2.0.0-beta, but will have to write at least a bit of documentation mentioning the breaking changes.

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

Successfully merging this pull request may close these issues.

Add Windows support or allow to pass in an initialized sqlite instance Use sqlite3 for wider platform support? Linux support
4 participants