{"id":16633171,"url":"https://github.com/be-hase/caffeine-coroutines","last_synced_at":"2025-03-21T15:31:27.384Z","repository":{"id":240406846,"uuid":"802042489","full_name":"be-hase/caffeine-coroutines","owner":"be-hase","description":"A simple extension that adds Kotlin Coroutines support to caffeine","archived":false,"fork":false,"pushed_at":"2025-03-14T19:32:45.000Z","size":193,"stargazers_count":11,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T20:33:02.017Z","etag":null,"topics":["cache","caffeine","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/be-hase.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":"2024-05-17T12:08:10.000Z","updated_at":"2025-03-14T19:32:48.000Z","dependencies_parsed_at":"2024-05-18T17:22:45.908Z","dependency_job_id":"269a855b-a5a3-43da-806b-4214fcce7095","html_url":"https://github.com/be-hase/caffeine-coroutines","commit_stats":null,"previous_names":["be-hase/caffeine-coroutines"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/be-hase%2Fcaffeine-coroutines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/be-hase%2Fcaffeine-coroutines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/be-hase%2Fcaffeine-coroutines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/be-hase%2Fcaffeine-coroutines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/be-hase","download_url":"https://codeload.github.com/be-hase/caffeine-coroutines/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244146193,"owners_count":20405787,"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":["cache","caffeine","kotlin"],"created_at":"2024-10-12T05:12:21.767Z","updated_at":"2025-03-21T15:31:26.936Z","avatar_url":"https://github.com/be-hase.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# caffeine-coroutines\n\n![Maven Central Version](https://img.shields.io/maven-central/v/dev.hsbrysk/caffeine-coroutines)\n\n## Motivation\n\nThere is a caching library called [Caffeine](https://github.com/ben-manes/caffeine),\nwhich is used as a de facto standard in Java.\n\nI will make this library usable with Kotlin Coroutines.\n\n## Install\n\n### Gradle\n\n```kotlin\nimplementation(\"dev.hsbrysk:caffeine-coroutines:{{version}}\")\n```\n\n### Maven\n\n```xml\n\n\u003cdependency\u003e\n    \u003cgroupId\u003edev.hsbrysk\u003c/groupId\u003e\n    \u003cartifactId\u003ecaffeine-coroutines\u003c/artifactId\u003e\n    \u003cversion\u003e{{version}}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## How to use\n\nThere is almost no difference from Caffeine.\nThe only thing you need to know is that by using *`buildCoroutine`*,\nyou can obtain a coroutine-compatible Cache instance.\n\n```kotlin\nsuspend fun main() {\n    val cache: CoroutineCache\u003cString, String\u003e = Caffeine.newBuilder()\n        .maximumSize(10_000)\n        .expireAfterWrite(Duration.ofMinutes(5))\n        .buildCoroutine() // Use buildCoroutine\n\n    val value = cache.get(\"key\") {\n        delay(1000) // You can use suspend functions.\n        \"value\"\n    }\n    println(value)\n}\n```\n\nOf course, it also supports the Loading Cache style.\n\n```kotlin\nsuspend fun main() {\n    val cache: CoroutineLoadingCache\u003cString, String\u003e = Caffeine.newBuilder()\n        .maximumSize(10_000)\n        .expireAfterWrite(Duration.ofMinutes(5))\n        .buildCoroutine { // Use buildCoroutine\n            delay(1000) // You can use suspend functions.\n            \"value\"\n        }\n\n    val value = cache.get(\"key\")\n    println(value)\n}\n```\n\n## Philosophy\n\n### We will primarily focus on coroutine support\n\nWe respect the widely used Caffeine API.\n\nIntroducing our own API would confuse users.\nIt would also make adoption more difficult and would be troublesome when discontinuing it after adoption.\n\n## Contributing\n\nIf there are any issues, please feel free to send a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbe-hase%2Fcaffeine-coroutines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbe-hase%2Fcaffeine-coroutines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbe-hase%2Fcaffeine-coroutines/lists"}