{"id":33147016,"url":"https://github.com/anupcowkur/Reservoir","last_synced_at":"2025-11-16T03:01:34.250Z","repository":{"id":12226148,"uuid":"14835409","full_name":"anupcowkur/Reservoir","owner":"anupcowkur","description":"Android library to easily serialize and cache your objects to disk using key/value pairs.","archived":true,"fork":false,"pushed_at":"2020-12-15T11:13:58.000Z","size":696,"stargazers_count":663,"open_issues_count":0,"forks_count":76,"subscribers_count":29,"default_branch":"master","last_synced_at":"2023-12-16T15:56:43.694Z","etag":null,"topics":["android","android-library","async","asynchronous","cache","disklrucache","gson","java","reservoir","rxjava","serialization"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anupcowkur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-01T07:52:35.000Z","updated_at":"2023-11-12T14:13:25.000Z","dependencies_parsed_at":"2022-08-30T09:20:37.941Z","dependency_job_id":null,"html_url":"https://github.com/anupcowkur/Reservoir","commit_stats":null,"previous_names":[],"tags_count":8,"template":null,"template_full_name":null,"purl":"pkg:github/anupcowkur/Reservoir","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anupcowkur%2FReservoir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anupcowkur%2FReservoir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anupcowkur%2FReservoir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anupcowkur%2FReservoir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anupcowkur","download_url":"https://codeload.github.com/anupcowkur/Reservoir/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anupcowkur%2FReservoir/sbom","scorecard":{"id":200079,"data":{"date":"2025-08-11","repo":{"name":"github.com/anupcowkur/Reservoir","commit":"4ef77a7959b3f6da040e64902b0e286808f1afae"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: gradle/wrapper/gradle-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: License.txt:0","Info: FSF or OSI recognized license: MIT License: License.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-16T22:39:39.725Z","repository_id":12226148,"created_at":"2025-08-16T22:39:39.725Z","updated_at":"2025-08-16T22:39:39.725Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284654194,"owners_count":27041729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","async","asynchronous","cache","disklrucache","gson","java","reservoir","rxjava","serialization"],"created_at":"2025-11-15T13:00:40.320Z","updated_at":"2025-11-16T03:01:34.245Z","avatar_url":"https://github.com/anupcowkur.png","language":"Java","funding_links":[],"categories":["Libs","缓存库","Cache"],"sub_categories":["\u003cA NAME=\"Utility\"\u003e\u003c/A\u003eUtility"],"readme":"# Deprecated\nThis project is no longer maintained. No new issues or pull requests will be accepted. You can still use the source or fork the project to suit your needs.\n\n\nReservoir\n=========\n\nReservoir is a simple library for Android that allows you to easily serialize and cache your objects to disk using key/value pairs.\n\n[ ![Download](https://api.bintray.com/packages/anupcowkur/maven/reservoir/images/download.svg) ](https://bintray.com/anupcowkur/maven/reservoir/_latestVersion)\n\n\u003ca href=\"http://www.methodscount.com/?lib=com.anupcowkur%3Areservoir%3A3.1.0\"\u003e\u003cimg src=\"https://img.shields.io/badge/Methods and size-core: 163 | deps: 1528 | 19 KB-e91e63.svg\"/\u003e\u003c/a\u003e\n\n# Including in your project\n\nAdd the jcenter repository to your gradle build file if it's not already present:\n\n```groovy\nrepositories {\n    jcenter()\n}\n```\n\nNext, add Reservoir as a dependency:\n\n```groovy\ndependencies {\n    compile 'com.anupcowkur:reservoir:3.1.0'\n}\n```\n\n# Usage\n\n## Initialize\nReservoir uses the internal cache storage allocated to your app. Before you can do anything, you need to initialize Reservoir with the cache size.\n\n```java\ntry {\n    Reservoir.init(this, 2048); //in bytes\n} catch (IOException e) {\n        //failure\n}\n```\n\nIf you want to pass in a custom GSON instance for whatever reason, you can do that too:\n\n```java\ntry {\n    Reservoir.init(this, 2048, myGsonInstance);\n} catch (IOException e) {\n        //failure\n}\n```\n\nThe best place to do this initialization would be in your application's `onCreate()` method.\n\nSince this library depends directly on [DiskLruCache](https://github.com/JakeWharton/DiskLruCache), you can refer that project for more info on the maximum size you can allocate etc.\n\n## Put stuff\n\nYou can put objects into Reservoir synchronously or asynchronously.\n\nAsync put will you give you a callback on completion:\n\n```java\n\n//Put a simple object\nReservoir.putAsync(\"myKey\", myObject, new ReservoirPutCallback() {\n            @Override\n            public void onSuccess() {\n                //success\n            }\n\n            @Override\n            public void onFailure(Exception e) {\n                //error\n            }\n        });\n\n\n//Put collection\nList\u003cString\u003e strings = new ArrayList\u003cString\u003e();\nstrings.add(\"one\");\nstrings.add(\"two\");\nstrings.add(\"three\");\nReservoir.putAsync(\"myKey\", strings, new ReservoirPutCallback() {\n            @Override\n            public void onSuccess() {\n                //success\n            }\n\n            @Override\n            public void onFailure(Exception e) {\n                //error\n            }\n        });        \n```\n\nsynchronous put:\n\n```java\n//Put a simple object\ntry {\n    Reservoir.put(\"myKey\", myObject);\n} catch (IOException e) {\n    //failure;\n}\n\n//Put collection\nList\u003cString\u003e strings = new ArrayList\u003cString\u003e();\nstrings.add(\"one\");\nstrings.add(\"two\");\nstrings.add(\"three\");\ntry {\n    Reservoir.put(\"myKey\", strings);\n} catch (IOException e) {\n    //failure;\n}\n```\n\nAsync put uses the standard AsyncTask provided by the Android framework.\n\n## Get Stuff\n\nYou can get stuff out of Reservoir synchronously or asynchronously as well.\n\nAsync get will give you a callback on completion:\n\n```java\n//Get a simple object\nReservoir.getAsync(\"myKey\", MyClass.class, new ReservoirGetCallback\u003cMyClass\u003e() {\n            @Override\n            public void onSuccess(MyClass myObject) {\n                //success\n            }\n\n            @Override\n            public void onFailure(Exception e) {\n                //error\n            }\n        });\n\n//Get collection\nType resultType = new TypeToken\u003cList\u003cString\u003e\u003e() {}.getType();\nReservoir.getAsync(\"myKey\", resultType, new ReservoirGetCallback\u003cList\u003cString\u003e\u003e() {\n            @Override\n            public void onSuccess(List\u003cString\u003e strings) {\n                //success\n            }\n\n            @Override\n            public void onFailure(Exception e) {\n                //error\n            }\n        });        \n```\n\nsynchronous get:\n\n```java\n//Get a simple object\ntry {\n    Reservoir.get(\"myKey\", MyClass.class);\n} catch (IOException e) {\n        //failure\n}\n\n//Get collection\nType resultType = new TypeToken\u003cList\u003cString\u003e\u003e() {}.getType();\ntry {\n    Reservoir.get(\"myKey\", resultType);\n} catch (IOException e) {\n        //failure\n}\n```\n\n## Check for existence\n\nIf you wish to know whether an object exists for the given key, you can use:\n\n```java\ntry {\n    boolean objectExists = Reservoir.contains(\"myKey\");\n} catch (IOException e) {}\n```\n\n## Delete Stuff\n\ndeleting stuff can also be synchronous or asynchronous.\n\nAsync delete will give you a callback on completion:\n\n```java\nReservoir.deleteAsync(\"myKey\", new ReservoirDeleteCallback() {\n            @Override\n            public void onSuccess(MyClass myObject) {\n                //success\n            }\n\n            @Override\n            public void onFailure(Exception e) {\n                //error\n            }\n        });\n```\n\nsynchronous delete:\n\n```java\ntry {\n    Reservoir.delete(\"myKey\");\n} catch (IOException e) {\n        //failure\n}\n```\n\n## Clearing the cache\n\nYou can clear the entire cache at once if you want. \n\nasynchronous clear:\n\n```java\nReservoir.clearAsync(new ReservoirClearCallback() {\n            @Override\n            public void onSuccess() {\n                try {\n                    assertEquals(0, Reservoir.bytesUsed());\n                } catch (Exception e) {\n                   \n                }\n            }\n\n            @Override\n            public void onFailure(Exception e) {\n                \n            }\n        });\n```\n\nsynchronous clear:\n\n```java\ntry {\n    Reservoir.clear();\n} catch (IOException e) {\n        //failure\n}\n```\n## RxJava\n\nReservoir is down with RxJava! All the async methods have RxJava variants that return observables. These observables are scheduled on a background thread and observed on the main thread by default (you can change this easily by assigning your own schedulers and observers to the returned observable).\n\nFirst, you'll need to add RxJava dependency to your app since Reservoir does not come bundled with it:\n\n```\ncompile 'io.reactivex:rxandroid:\u003crxandroid-version\u003e' - tested with v1.2.1\ncompile 'io.reactivex:rxjava:\u003crxjava-version\u003e' - tested with v1.1.6\n```\n\nThen you can use the RxJava variants of all the regular Reservoir methods.\n\nput:\n\n```java\n//Put a simple object\nReservoir.putUsingObservable(\"myKey\", myObject) returns Observable\u003cBoolean\u003e\n\n//Put collection\nList\u003cString\u003e strings = new ArrayList\u003cString\u003e();\nstrings.add(\"one\");\nstrings.add(\"two\");\nstrings.add(\"three\");\nReservoir.putUsingObservable(\"myKey\", strings) returns Observable\u003cBoolean\u003e\n```\n\nget:\n```java\n//Get a simple object\nReservoir.getUsingObservable(\"myKey\", MyClass.class) returns Observable\u003cMyClass\u003e\n\n//Get collection\n//Note : Rx observables return items one at a time. So even if you put in a complete collection, the items in the collection will be returned \n//one by one by the observable.\nType collectionType = new TypeToken\u003cList\u003cString\u003e\u003e() {}.getType();\nReservoir.getUsingObservable(\"myKey\", String.class, collectionType) returns Observable\u003cString\u003e\n```\n\ndelete:\n```java\nReservoir.deleteUsingObservable(\"myKey\") returns Observable\u003cBoolean\u003e\n```\n\nclear:\n```java\nReservoir.clearUsingObservable() returns Observable\u003cBoolean\u003e\n```\n\nIf you'd like to see examples of using these observables, check out the [tests in the sample application](https://github.com/anupcowkur/Reservoir/blob/master/Sample/src/androidTest/java/com/anupcowkur/reservoir/ReservoirTest.java).\n\n# FAQs\n\n## What kind of objects can I add to Reservoir?\nAnything that GSON can serialize.\n\n## What happens if my cache size is exceeded?\nOlder objects will be removed in a LRU (Least Recently Used) order.\n\n## Can I use this a SharedPreferences replacement?\nNO! This is a cache. You should store stuff in here that is good to have around, but you wouldn't mind if they were to be removed. SharedPreferences are meant to store user preferences which is not something you want to lose.\n\n# Sample\nCheck out the [sample application tests](https://github.com/anupcowkur/Reservoir/blob/master/Sample/src/androidTest/java/com/anupcowkur/reservoir/ReservoirTest.java) for complete examples of API usage.\n\n# Contributing\nContributions welcome via Github pull requests.\n\n# Credits\nReservoir is just a tiny little convenience wrapper around the following fantastic projects:\n\n- [DiskLruCache](https://github.com/JakeWharton/DiskLruCache)\n- [SimpeDiskCache](https://github.com/fhucho/simple-disk-cache)\n- [GSON](https://code.google.com/p/google-gson/)\n- [RxAndroid](https://github.com/ReactiveX/RxAndroid)\n\n# License\nThis project is licensed under the MIT License. Please refer the [License.txt](https://github.com/anupcowkur/Reservoir/blob/master/License.txt) file.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanupcowkur%2FReservoir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanupcowkur%2FReservoir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanupcowkur%2FReservoir/lists"}