{"id":51899944,"url":"https://github.com/drupol/cacache-ttl","last_synced_at":"2026-07-26T14:02:52.883Z","repository":{"id":355891822,"uuid":"1230096402","full_name":"drupol/cacache-ttl","owner":"drupol","description":"TTL decorator for cacache.","archived":false,"fork":false,"pushed_at":"2026-06-22T08:20:05.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-29T08:31:31.071Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"eupl-1.2","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drupol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"drupol"}},"created_at":"2026-05-05T17:13:06.000Z","updated_at":"2026-06-22T08:20:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/drupol/cacache-ttl","commit_stats":null,"previous_names":["drupol/cacache-ttl"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/drupol/cacache-ttl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupol%2Fcacache-ttl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupol%2Fcacache-ttl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupol%2Fcacache-ttl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupol%2Fcacache-ttl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drupol","download_url":"https://codeload.github.com/drupol/cacache-ttl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drupol%2Fcacache-ttl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35916664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-26T02:00:06.503Z","response_time":89,"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":[],"created_at":"2026-07-26T14:02:52.259Z","updated_at":"2026-07-26T14:02:52.869Z","avatar_url":"https://github.com/drupol.png","language":"Rust","funding_links":["https://github.com/sponsors/drupol"],"categories":[],"sub_categories":[],"readme":"![GitHub stars][GitHub stars]\n[![Crates.io Version][Crates.io Version]][cacache-ttl crates]\n[![Crates.io License][Crates.io License]][cacache-ttl crates]\n[![Donate!][Donate!]][sponsor link]\n\n# Cacache TTL\n\n`cacache-ttl` is a [decorator] for [`cacache`](https://crates.io/crates/cacache)\nthat adds per-entry [TTL] support while keeping the same read/write style.\n\nThe crate stores expiration data in the `cacache` index metadata under\n`expires_at_millis`. Cache content is still written and read by `cacache`\nitself.\n\n## Usage\n\nSynchronous:\n\n```rust\nuse std::time::Duration;\n\nfn main() -\u003e cacache_ttl::Result\u003c()\u003e {\n    let cache = \"./target/example-cache\";\n    let key = \"github-response\";\n\n    cacache_ttl::write_sync(cache, key, b\"cached bytes\", Duration::from_secs(300))?;\n    let bytes = cacache_ttl::read_sync(cache, key)?;\n\n    assert_eq!(bytes, b\"cached bytes\");\n    Ok(())\n}\n```\n\nAsynchronous:\n\n```rust\nuse std::time::Duration;\n\n#[tokio::main]\nasync fn main() -\u003e cacache_ttl::Result\u003c()\u003e {\n    let cache = \"./target/example-cache\";\n    let key = \"github-response\";\n\n    cacache_ttl::write(cache, key, b\"cached bytes\", Duration::from_secs(300)).await?;\n    let bytes = cacache_ttl::read(cache, key).await?;\n\n    assert_eq!(bytes, b\"cached bytes\");\n    Ok(())\n}\n```\n\n## Expiration Behavior\n\nExpired entries are removed from the `cacache` index with `cacache::remove` /\n`cacache::remove_sync`, then returned as\n`cacache_ttl::Error::EntryNotFoundOrExpired`, which is also used for missing\nentries.\n\n`cacache::remove` removes the index entry only; the content-addressed bytes may\nremain in the cache until normal cache maintenance clears unused content.\n\nCalling `write` or `write_sync` preserves existing JSON metadata and raw\nmetadata for the key, then adds or updates `expires_at_millis`.\n\n## API\n\n- `read(cache, key)`: async TTL-aware read.\n- `read_sync(cache, key)`: synchronous TTL-aware read.\n- `list_sync(cache)`: synchronous TTL-aware index listing.\n- `write(cache, key, data, ttl)`: async write with TTL.\n- `write_sync(cache, key, data, ttl)`: synchronous write with TTL.\n- `Error::EntryNotFoundOrExpired(cache, key)`: missing or expired cache entry.\n\n[decorator]: https://en.wikipedia.org/wiki/Decorator_pattern\n[GitHub stars]: https://img.shields.io/github/stars/drupol/cacache-ttl.svg?style=flat-square\n[Donate!]: https://img.shields.io/badge/Sponsor-Github-brightgreen.svg?style=flat-square\n[sponsor link]: https://github.com/sponsors/drupol\n[Crates.io License]: https://img.shields.io/crates/l/cacache-ttl?style=flat-square\n[Crates.io Version]: https://img.shields.io/crates/v/cacache-ttl?style=flat-square\n[cacache-ttl crates]: https://crates.io/crates/cacache-ttl\n[TTL]: https://en.wikipedia.org/wiki/Time_to_live\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrupol%2Fcacache-ttl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrupol%2Fcacache-ttl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrupol%2Fcacache-ttl/lists"}