{"id":23141617,"url":"https://github.com/zekrotja/timedmap-rs","last_synced_at":"2025-07-07T12:06:40.731Z","repository":{"id":167247584,"uuid":"642835359","full_name":"zekroTJA/timedmap-rs","owner":"zekroTJA","description":"A thread-safe hash map with expiring key-value pairs.","archived":false,"fork":false,"pushed_at":"2024-03-26T14:15:14.000Z","size":23,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-06T18:53:51.086Z","etag":null,"topics":["cache","cache-map","crate","hacktoberfest","hashmap","library","map","rust","time","timemap"],"latest_commit_sha":null,"homepage":"https://docs.rs/timedmap","language":"Rust","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/zekroTJA.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}},"created_at":"2023-05-19T13:01:31.000Z","updated_at":"2024-07-30T18:18:04.000Z","dependencies_parsed_at":"2024-03-26T15:32:27.685Z","dependency_job_id":"f0008fb2-1179-4df1-8060-cda6bcedaf3b","html_url":"https://github.com/zekroTJA/timedmap-rs","commit_stats":null,"previous_names":["zekrotja/timedmap-rs"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zekroTJA%2Ftimedmap-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zekroTJA%2Ftimedmap-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zekroTJA%2Ftimedmap-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zekroTJA%2Ftimedmap-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zekroTJA","download_url":"https://codeload.github.com/zekroTJA/timedmap-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230128406,"owners_count":18177599,"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","cache-map","crate","hacktoberfest","hashmap","library","map","rust","time","timemap"],"created_at":"2024-12-17T14:14:02.729Z","updated_at":"2024-12-17T14:14:03.486Z","avatar_url":"https://github.com/zekroTJA.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# timedmap [![Crates.io](https://img.shields.io/crates/v/timedmap)](https://crates.io/crates/timedmap) [![docs.rs](https://img.shields.io/docsrs/timedmap)](https://docs.rs/timedmap)\n\nA *more or less* port of my package [timedmap](https://github.com/zekrotja/timedmap) - originally written in Go - but for Rust!\n\n`timedmap` provides a thread-safe hash map with expiring key-value pairs and\nautomatic cleanup mechnaisms for popular async runtimes.\n\n# Basic Example\n```rust\nuse timedmap::TimedMap;\nuse std::time::Duration;\n\nlet tm = TimedMap::new();\ntm.insert(\"foo\", 1, Duration::from_millis(100));\ntm.insert(\"bar\", 2, Duration::from_millis(200));\ntm.insert(\"baz\", 3, Duration::from_millis(300));\nassert_eq!(tm.get(\u0026\"foo\"), Some(1));\nassert_eq!(tm.get(\u0026\"bar\"), Some(2));\nassert_eq!(tm.get(\u0026\"baz\"), Some(3));\n\nstd::thread::sleep(Duration::from_millis(120));\nassert_eq!(tm.get(\u0026\"foo\"), None);\nassert_eq!(tm.get(\u0026\"bar\"), Some(2));\nassert_eq!(tm.get(\u0026\"baz\"), Some(3));\n\nstd::thread::sleep(Duration::from_millis(100));\nassert_eq!(tm.get(\u0026\"foo\"), None);\nassert_eq!(tm.get(\u0026\"bar\"), None);\nassert_eq!(tm.get(\u0026\"baz\"), Some(3));\n```\n\n# Cleanup Example\n\nYou can use the `start_cleaner` function to automatically clean up\nexpired key-value pairs in given time intervals using popular\nasync runtimes.\n\n\u003e Currently, only implementations for `tokio` and `actix-rt`\n\u003e are available. Implentations for other popular runtimes are\n\u003e planned in the future. If you want to contribute an implementation,\n\u003e feel free to create a\n\u003e [pull request](https://github.com/zekroTJA/timedmap-rs). 😄\n\n```rust\nuse timedmap::{TimedMap, start_cleaner};\nuse std::time::Duration;\nuse std::sync::Arc;\n\nlet tm = Arc::new(TimedMap::new());\ntm.insert(\"foo\", 1, Duration::from_secs(60));\n\nlet cancel = start_cleaner(tm, Duration::from_secs(10));\n\ncancel();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzekrotja%2Ftimedmap-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzekrotja%2Ftimedmap-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzekrotja%2Ftimedmap-rs/lists"}