Store/cache
Eyal Guthmann e773021fec
Revert to use the old guava port cache (via jar) (#200)
* Revert to using guava port cache by depending on jar

* Apply suggestions from code review

* revert code to old cache

* clean up build.gradle

* manually remove cache4 entries that are regenerated locally because of some dirty cache?

* bump gradle

* rerun tasks

* try to deflake rx tests

* cache builder tests

* api dump

* bump ktlint to work with 1.4 features

* formatting

Co-authored-by: Mike Nakhimovich <digitalbuddha@users.noreply.github.com>
2020-09-14 14:49:34 -07:00
..
api Revert to use the old guava port cache (via jar) (#200) 2020-09-14 14:49:34 -07:00
src/main/java/com/dropbox/android/external/cache3 Revert to use the old guava port cache (via jar) (#200) 2020-09-14 14:49:34 -07:00
.gitignore initial 2017-01-04 14:17:53 -05:00
build.gradle Revert to use the old guava port cache (via jar) (#200) 2020-09-14 14:49:34 -07:00
gradle.properties Switch POM packaging format to jar for cache, filesystem and store. (#54) 2020-01-07 13:31:19 -05:00
README.md Revert to use the old guava port cache (via jar) (#200) 2020-09-14 14:49:34 -07: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

	implementation 'com.dropbox.android:cache3:3.0.0-beta'
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.