{"id":31833513,"url":"https://github.com/oastuff/timedmap","last_synced_at":"2025-10-11T23:56:03.459Z","repository":{"id":57658601,"uuid":"110960815","full_name":"oaStuff/timedMap","owner":"oaStuff","description":"A go implementation of timed map with automatic items expiration (golang)","archived":false,"fork":false,"pushed_at":"2017-11-26T20:14:32.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-21T04:41:49.807Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oaStuff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-16T11:00:57.000Z","updated_at":"2017-11-16T11:16:09.000Z","dependencies_parsed_at":"2022-09-16T04:40:18.029Z","dependency_job_id":null,"html_url":"https://github.com/oaStuff/timedMap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oaStuff/timedMap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oaStuff%2FtimedMap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oaStuff%2FtimedMap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oaStuff%2FtimedMap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oaStuff%2FtimedMap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oaStuff","download_url":"https://codeload.github.com/oaStuff/timedMap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oaStuff%2FtimedMap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009367,"owners_count":26084582,"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-10-11T02:00:06.511Z","response_time":55,"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":"2025-10-11T23:55:42.909Z","updated_at":"2025-10-11T23:56:03.449Z","avatar_url":"https://github.com/oaStuff.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# timedMap\n\ntimedMap is simple go 1.9 sync.map with timing added. This implies that timedMap just\nstores items in a map and expires them automatically based on the time duration set.\n## usage\n\nImport the package:\n\n```go\nimport (\n\t\"github.com/oaStuff/timedMap\"\n)\n\n```\n\n```bash\ngo get \"github.com/oaStuff/timedMap\"\n```\n\n\n## example\n\n```go\n\n        //create the map\n\t    tm := timedMap.NewTimeMap(time.Second * 3, nil) // we want items to live in the map for only 3 seconds\n    \ttm.Add(\"one\",\"1\")\n    \ttm.Add(\"two\",\"2\")\n    \ttm.Add(\"three\", \"3\")\n\n    \tval := tm.Get(\"one\")\n    \tfmt.Println(\"value is \" + val)\n\n```\n\n## another example\n\n```go\n    type user struct {\n        name string\n        age int\n    }\n    \n    tm := timedMap.NewTimeMap(time.Second * 3, nil)\n\ttm.Add(\"john\", \u0026user{\"john mark\", 30})\n\ttm.Add(\"mary\", \u0026user{\"mary jane\", 26})\n\ttm.Add(\"paul\", \u0026user{\"paul frank\", 19})\n\n\tval = tm.Get(\"mary\")\n\tif val != nil {\n\t    fmt.Println(val.(*user).name)\n\t    fmt.Println(val.(*user).age)\n\t}\n```\n\nThe library also supports eviction callback when an item in the map expires.\n```go\n\n    type user struct {\n        name string\n        age int\n    }\n    tm := timedMap.NewTimeMap(time.Second * 3, func(key, value interface{}) {\n        fmt.Println(\"expried callback:\")\n        fmt.Printf(\"%+v\\n\", key)\n        fmt.Printf(\"%+v\\n\", value)\n    })\n    \n\ttm.Add(\"john\", \u0026user{\"john mark\", 30})\n\ttm.Add(\"mary\", \u0026user{\"mary jane\", 26})\n\ttm.Add(\"paul\", \u0026user{\"paul frank\", 19})\n\n    time.Sleep(time.Second * 5)\n\tval = tm.Get(\"mary\")\n\tif val != nil {\n\t    fmt.Println(val.(*user).name)\n\t    fmt.Println(val.(*user).age)\n\t}\n```\n\n## license\nMIT (see [LICENSE](https://github.com/orcaman/concurrent-map/blob/master/LICENSE) file)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foastuff%2Ftimedmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foastuff%2Ftimedmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foastuff%2Ftimedmap/lists"}