Store/cache
Ramona Harrison 2c2872504b Include develop changes in Rx2 branch (#214)
* Update README.md

* Update README.md

* Update README.md (#175)

* Update README.md

* Close source after  write to filesystem

* Refactor FSFileTest to rx2 package

* remove null check on source and annotate arg with NonNull

* Standardize store.stream() to only emit new items

* Standardize store.stream() to only emit new items

* Remove unneeded call to asObservable()

* Update README.md

* Update README.md

* Fixed PMD violation God Class for RealInternalStore (#179)

* Update README.md

* Fixing dependency importation typo (#186)

* Mike/test (#195)

* new test

* Refactor NoNetworkTest to rx2 package

* Typo fixed (#202)

* Typo fixed

* Simplified by removing generics

* Update build.gradle (#193)

rename app id for sample app

* Add a missing Source.close() call (#200)

* Add Retrolambda plugin on the rest modules (#205)

* Add Retrolambda plugin on the rest modules and modify sample app for new config

* Suppress PMD violation on equals()

* Add Raw to BufferedSource transformer (#198)

* expireAfterAccess added to MemoryPolicy (#199)

* Add test coverage for MemoryPolicyBuilder (#210)

* Add test coverage for MemoryPolicyBuilder

* Checkstyle new line at EOF

* Fix PMD

* Refactor MemoryPolicyBuilderTest to rx2 package

* Deprecate setExpireAfter and getExpireAfter (#211)
2017-05-19 10:25:04 -04:00
..
src/main Include develop changes in Rx2 branch (#214) 2017-05-19 10:25:04 -04:00
.gitignore initial 2017-01-04 14:17:53 -05:00
build.gradle Include develop changes in Rx2 branch (#214) 2017-05-19 10:25:04 -04:00
gradle.properties initial 2017-01-04 14:17:53 -05:00
Readme.md Prepare for release 2.0.0. 2017-02-13 11:37:12 -05:00

Cache

Store depends on a subset of Guava, we have extracted these parts into a shaded Cache artifact.
Feel free to use Cache anytime you need an in memory cache implementation optimized for Android.

To use, first build a cache instance.

 memCache = CacheBuilder.newBuilder()
                .maximumSize(getCacheSize())
                .expireAfterAccess(getCacheTTL(), TimeUnit.SECONDS)
                .build();

You can then use your cache as regular cache or one that knows how to load itself (with blocking) when empty

memCache.get(key, new Callable<T>() {
                @Override
                public Observable<T> call() throws Exception {
                    return getCachedValue(key);
                }
            });

Please refer to Guava's Cache documentation for additional features/configurations https://github.com/google/guava/wiki/CachesExplained

	compile 'com.nytimes.android:cache:2.0.0'
Copyright (c) 2017 The New York Times Company

Copyright (c) 2010 The Guava Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this library except in 
compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
language governing permissions and limitations under the License.