Comments (7)
This is a policy decision in the API. You can manually call flush() in your own code if you'd like to flush the journal after every write. DiskLruCache doesn't do this by default because it wants to minimize the number of slow disk writes it makes.
from disklrucache.
That said, this does need to be documented!
from disklrucache.
I see your point. I'd like not flush journal after every write, only after write "CLEAN" or "DIRTY", while not flush after write "READ"(not worth to do).
Back to my case, my app is an android app which may be closed or interrupted unpredictably, and I has only one chance to create a cache(after a video is downloaded) and use it elsewhere. If someone has the similar case with me, I suggest flush after every commit immediately.
from disklrucache.
@swankjesse could you suggest where it is better to flush DiskLruCache for Android apps to prevent loosing of image cache after app close or crash?
from disklrucache.
Calling flush after committing an edit would work.
from disklrucache.
Thanks!
from disklrucache.
Thank you so much for this, flush works!
from disklrucache.
Related Issues (20)
- Clear Cache HOT 1
- Copyright (C) 2011 The Android Open Source Project Copyright 2012 Jake Wharton Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- executorService is not shut down
- Can you support the OpenHarmony JavaScript version? HOT 1
- Does getCacheDir() supported? HOT 3
- Simplify interface and make lib truly asynchronous HOT 4
- Multi-thread: Infinite loop in trimToSize HOT 5
- Closing the correct resource ? HOT 1
- Validate key Issue HOT 1
- max size doesn't take in consideration minimum 4kb block size. HOT 2
- Files disappear after a while HOT 1
- Old Image is always shown HOT 1
- Basic usage and code samples? HOT 1
- [Question] Where is the performence report of DiskLruCache? HOT 1
- what can cause cache is closed
- Hey! 61 tests 10 failed I have... HOT 5
- Request for new release 2.0.3 HOT 1
- Get entry count/iterator
- while loop in StrictLineReader.java HOT 2
- Key length is 64 for dependencies resolved via maven/jcenter HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from disklrucache.