Comments (3)
This is by intention. Reservoir is meant to be used as a singleton. Creating multiple instances will lead to confusion (Which instance did I put this object into?) and duplication (putting the same object into multiple instances) which makes things harder for developer.
The benefits in this case don't outweigh the costs.
from reservoir.
Singleton is very bad design pattern and commonly used only for system-wide services. But it is not right to use it for the cache, because user may need multiple caches in his app with different lifetime and size values.
And yes, cache instance must be aggregated inside the class that uses the cache, because it is implementation detail of that class which must not interfere with any other class that uses the cache. It is encapsulation.
That's why Android in-memory LruCache is not singleton.
from reservoir.
Sorry, but I disagree. Reservoir is better off as a singleton so as to provide a simple disk based cache. It might be the case for other libs where lifetime and size values are more relevant but not for a fire and forget minimalistic disk cache.
from reservoir.
Related Issues (20)
- RxAndroid as a provided dependency HOT 1
- Failed to invoke protected java.text.DateFormat() with no args HOT 1
- Is there any way to set expiry date for a cached object? HOT 1
- cannot access Observable class file for rx.Observable not found HOT 10
- this project support multiprocess operation ? HOT 1
- Proguard Rules HOT 2
- GSON Error HOT 1
- A/libc: Fatal signal 11 (SIGSEGV) HOT 2
- Declares multiple JSON fields named id HOT 3
- bytesUsed not working HOT 1
- Add more specific exceptions in README HOT 1
- null object reference! HOT 3
- Any chance for iOS ? HOT 1
- Invalidate Cache when app updates HOT 1
- ability to cancel asynctask HOT 1
- Would be support of RxJava2? HOT 2
- rx.java seems not optionable - `Failed resolution of rx/Observable$onSubscribe` error HOT 1
- Can we put multiple keys into cache? HOT 3
- Replace RxJava 1 with RxJava 2 HOT 4
- What can be the causes for faliure for storing HOT 2
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 reservoir.