Comments (3)
Just a small note here, if you are using GSON you can very easily convert your Stock object to a BufferedSource.
Buffer buffer = new Buffer();
Gson gson = new Gson();
buffer.write(gson.toJson(yourObjectGoesHere).getBytes());
buffer.flush();
buffer.close();
from store.
Currently the file system impelentation needs a stream from network. As a result SourcePersisterFactory cannot work with an input of a scalar value like Stock. What you can do is write your own persister which can still use the FileSystem, within your read/write impelentation you can do the conversion from your data type to a BufferedSource. Use the SourcePersisterFactory as an example (there should be a test for it which shows how to create a bufferedsource from a string)
You're also free to create a new middleware for this and we will merge it in.
Alternatively you can use your own persister without our file system and write a persister implementation that can work with an input/output of Stock.
from store.
one more helper method how to go from a string to a bufferedsource
private static BufferedSource source(String data) {
return Okio.buffer(Okio.source(new ByteArrayInputStream(data.getBytes(UTF_8))));
}
from store.
Related Issues (20)
- Store 4 design document HOT 2
- Observe changes in disk without invalidating cache HOT 2
- NetworkOnMainThread thrown when performing a clear from the MainThread HOT 1
- Question: Convert List<T> From API to BufferedSource
- Question: Shouldn't Persister.write return single which will write to cache only after subscribe? HOT 2
- Sample crashes on launch
- Get data always hits the network without persister HOT 5
- Clear FileSystemPersister HOT 1
- Support for partial fetches (for paginated APIs) HOT 1
- Clearable HOT 2
- Feature Request : support for multiple get/fetch HOT 1
- RecordPersister's 'Expiration' is not working HOT 8
- Misleading docs and behavior of Store.clear() HOT 6
- How to determine if a key is in memory cache? HOT 3
- fetchWithResult returns NETWORK even on network errors HOT 2
- Issue with gradle plugin 3.4.0 HOT 11
- Provide a method for getting data from memory cache
- Having trouble fetching data using android nytimes store library HOT 1
- Request is made multiple times
- This library seems to be deprecated. Other alternatives? 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 store.