{"id":13611187,"url":"https://github.com/pyamsoft/cachify","last_synced_at":"2026-01-19T23:48:46.764Z","repository":{"id":36981147,"uuid":"193628231","full_name":"pyamsoft/cachify","owner":"pyamsoft","description":"Simple in-memory caching of all the things","archived":false,"fork":false,"pushed_at":"2024-10-27T19:12:21.000Z","size":1022,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-27T23:43:29.450Z","etag":null,"topics":["android","cachify","caching","kotlin"],"latest_commit_sha":null,"homepage":"https://pyamsoft.blogspot.com/","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyamsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-25T03:29:26.000Z","updated_at":"2024-10-27T19:12:25.000Z","dependencies_parsed_at":"2023-10-02T19:46:43.183Z","dependency_job_id":"d28bff59-0281-49a3-b1b1-aeb7302df203","html_url":"https://github.com/pyamsoft/cachify","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyamsoft%2Fcachify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyamsoft%2Fcachify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyamsoft%2Fcachify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyamsoft%2Fcachify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyamsoft","download_url":"https://codeload.github.com/pyamsoft/cachify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223558606,"owners_count":17165156,"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","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","cachify","caching","kotlin"],"created_at":"2024-08-01T19:01:52.635Z","updated_at":"2026-01-19T23:48:46.713Z","avatar_url":"https://github.com/pyamsoft.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# Cachify\n\nSimple in-memory cache of all the things\n\n## Install\n\nIn your `build.gradle`\n\n```gradle\nrepositories {\n\n  maven {\n    url 'https://jitpack.io'\n    content {\n      includeGroup(\"com.github.pyamsoft\")\n    }\n  }\n}\n\ndependencies {\n  def latestVersion = \"0.0.26\"\n\n  implementation \"com.github.pyamsoft:cachify:$latestVersion\"\n}\n```\n\n## Usage\n\nLet us assume you have, for example, an upstream network source using\n[Retrofit](https://github.com/square/retrofit) that is fetching a `Single\u003cList\u003cPeople\u003e\u003e`\n\nLife without Cachify:\n```kotlin\ninterface RxService {\n\n  @GET(\"/rx/service/names\")\n  fun names(filterBy: String, maxCount: Long, minLength: Int) : Single\u003cList\u003cPeople\u003e\u003e\n\n}\n\nclass RxCaller {\n\n  private val service = createService(RxService::class.java)\n\n  fun listNames() {\n    service.names(filterBy = \"John\", maxCount = 30L, minLength = 3)\n      .map { transformPeople(it) }\n      .subscribeOn(Schedulers.io())\n      .observeOn(AndroidSchedulers.mainThread())\n      .subscribe()\n  }\n\n}\n```\n\nNew fancy Cachify lifestyle:\n```kotlin\ninterface RxService {\n\n  @GET(\"/rx/service/names\")\n  fun names(filterBy: String, maxCount: Long, minLength: Int) : Single\u003cList\u003cPeople\u003e\u003e\n\n}\n\nclass RxCaller {\n\n  private val service = createService(RxService::class.java)\n\n  private val nameCache = cachify\u003cSingle\u003cList\u003cPeople\u003e\u003e, String, Long, Int\u003e { filterBy, maxCount, minLength -\u003e\n    service.names(filterBy = filterBy, maxCount = maxCount, minLength = minLength)\n  }\n\n  suspend fun listNames() {\n    nameCache.call(\"John\", 30L, 3)\n      .map { transformPeople(it) }\n      .subscribeOn(Schedulers.io())\n      .observeOn(AndroidSchedulers.mainThread())\n      .subscribe()\n  }\n\n}\n```\n\nSubsequent calls to the cache instance will always return the same data as\nlong as the timeout period has not elapsed. The timeout period is configurable\nper cache instance, and defaults to 30 seconds.\n\nIf you ever want to sidestep the cache and force the upstream data source to be\nqueried, or you just want to clear old cached data, you can call the `clear()` method\nwhich will erase any cached data currently held.\n\nYou can use the `cachify` entry point for a simple cache over a single value, but for more\ncomplex data, you can use the `multiCachify` entry point which differentiates your cached values\nby using creating a mapping from unique keys to cached values.\n\n```kotlin\ninterface DetailService {\n\n  suspend fun detail(id: String, userName: String) : Details\n\n}\n\nclass DetailCaller {\n\n  private val service = createService(DetailService::class.java)\n\n  private val detailCache = multiCachify\u003cDetailId, Details, String, String\u003e { id, userName -\u003e\n    service.detail(id = id, userName = userName)\n  }\n\n  suspend fun getDetailsFor(id: String): Details {\n    return detailCache.key(id).call(id, \"john.doe@example.com\")\n  }\n\n}\n```\n\n## Development\n\nCachify is developed in the Open on GitHub at:\n\n```\nhttps://github.com/pyamsoft/cachify\n```\n\nIf you know a few things about Android programming and are wanting to help\nout with development you can do so by creating issue tickets to squash bugs,\nand propose feature requests for future inclusion.\n\n# Issues or Questions\n\nPlease post any issues with the code in the Issues section on GitHub. Pull Requests\nwill be accepted on GitHub only after extensive reading and as long as the request\ngoes in line with the design of the application.\n\n## License\n\nApache 2\n\n```\nCopyright 2023 pyamsoft\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyamsoft%2Fcachify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyamsoft%2Fcachify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyamsoft%2Fcachify/lists"}