{"id":19511645,"url":"https://github.com/0xc000022070/filecache","last_synced_at":"2025-11-20T03:02:38.712Z","repository":{"id":244596865,"uuid":"815701743","full_name":"0xc000022070/filecache","owner":"0xc000022070","description":"A simple and modern cache implementation based on memory and then in FS written in Go","archived":false,"fork":false,"pushed_at":"2024-06-17T22:25:36.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-25T23:15:08.877Z","etag":null,"topics":["cache","file-based-cache","filesystem","library"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/0xc000022070/filecache","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/0xc000022070.png","metadata":{"files":{"readme":".github/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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-15T22:09:08.000Z","updated_at":"2024-10-12T05:13:16.000Z","dependencies_parsed_at":"2024-06-15T23:34:01.751Z","dependency_job_id":"fba47b18-3258-42c1-b765-828501525ff0","html_url":"https://github.com/0xc000022070/filecache","commit_stats":null,"previous_names":["0xc000022070/filecache"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/0xc000022070/filecache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xc000022070%2Ffilecache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xc000022070%2Ffilecache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xc000022070%2Ffilecache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xc000022070%2Ffilecache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xc000022070","download_url":"https://codeload.github.com/0xc000022070/filecache/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xc000022070%2Ffilecache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285363723,"owners_count":27159018,"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-11-20T02:00:05.334Z","response_time":54,"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":["cache","file-based-cache","filesystem","library"],"created_at":"2024-11-10T23:22:04.561Z","updated_at":"2025-11-20T03:02:38.678Z","avatar_url":"https://github.com/0xc000022070.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# File cache\n\n![Go workflow](https://github.com/0xc000022070/filecache/actions/workflows/go.yml/badge.svg)\n\nA simple modern file-based cache implementation written in Go.\n\nInspired by [gokyle/filecache](https://github.com/gokyle/filecache).\n\n## Install\n\n```shell\n# Requires Go 1.18 or later\n $ go get -u github.com/0xc000022070/filecache@latest\n```\n\n## API\n\n### Examples\n\n#### Simple\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"os\"\n    \"time\"\n\n    \"github.com/0xc000022070/filecache\"\n)\n\nfunc main() {\n    cache := filecache.New(\"showcase-1\",\n        filecache.WithTTL(time.Hour),\n        filecache.WithMaxSize(filecache.Megabyte*100),\n        filecache.WithCheckInterval(time.Minute*3),\n    )\n\n    // if you don't want to destroy it from the FS\n    // use `cache.Shutdown()`.\n    defer cache.Destroy()\n\n    // Try to handle ErrToLarge, ErrInvalidKey, etc.\n    err := cache.Set(\"my-showcase-content.txt\", []byte(\"heeey!\"))\n    if err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n\n    content, err := cache.Get(\"my-showcase-content.txt\")\n    if err != nil {\n        fmt.Fprintln(os.Stderr, err)\n        os.Exit(1)\n    }\n\n    fmt.Fprintf(os.Stdout, \"%s\\n\", content) // heeey!\n}\n\n```\n\n#### Using generics\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"os\"\n    \"time\"\n\n    \"github.com/0xc000022070/filecache\"\n)\n\nfunc main() {\n    cache := filecache.New(\"showcase-2\",\n        filecache.WithTTL(time.Minute*5),\n        filecache.WithMaxSize(filecache.Gigabyte),\n        filecache.WithCheckInterval(time.Minute),\n    )\n\n    // It will not be destroyed from the FS, so it can be used in another program call.\n    defer cache.Shutdown()\n\n    type UserData struct {\n        Name  string\n        Email string\n    }\n\n    users := []UserData{\n        {\n            Name:  \"John Doe\",\n            Email: \"john@doe.com\",\n        },\n        {\n            Name:  \"Jane Doe\",\n            Email: \"jane@doe.com\",\n        },\n    }\n\n    for _, user := range users {\n        key := fmt.Sprintf(\"user-%s\", user.Email)\n\n        // (encoded as glob)\n        if err := filecache.SetEncoded(cache, key, user); err != nil {\n            fmt.Fprintln(os.Stderr, err)\n        }\n\n        user2, err := filecache.GetDecoded[UserData](cache, key)\n        if err != nil {\n            fmt.Fprintln(os.Stderr, err)\n            os.Exit(1)\n        }\n\n        fmt.Fprintf(os.Stdout, \"%s \u003c%s\u003e\\n\", user2.Name, user2.Email)\n    }\n\n    if !cache.Exists(fmt.Sprintf(\"user-%s\", users[0].Email)) {\n        fmt.Fprintln(os.Stderr, \"user not found\")\n        os.Exit(1)\n    }\n}\n```\n\n## License\n\nThis project is licensed under the ISC License - see the [LICENSE](./LICENSE.md) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xc000022070%2Ffilecache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xc000022070%2Ffilecache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xc000022070%2Ffilecache/lists"}