{"id":18494804,"url":"https://github.com/gbrlsnchs/filecache","last_synced_at":"2025-09-13T13:27:59.153Z","repository":{"id":57552515,"uuid":"145919230","full_name":"gbrlsnchs/filecache","owner":"gbrlsnchs","description":"Fast in-memory file caching for Go :zap:","archived":false,"fork":false,"pushed_at":"2018-10-24T18:09:58.000Z","size":47,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-06T10:37:17.527Z","etag":null,"topics":["cache","context-aware","fast","file","in-memory","in-memory-caching","radix-tree"],"latest_commit_sha":null,"homepage":"","language":"Go","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/gbrlsnchs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-23T23:49:14.000Z","updated_at":"2020-02-11T18:47:19.000Z","dependencies_parsed_at":"2022-09-20T12:52:09.661Z","dependency_job_id":null,"html_url":"https://github.com/gbrlsnchs/filecache","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/gbrlsnchs/filecache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrlsnchs%2Ffilecache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrlsnchs%2Ffilecache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrlsnchs%2Ffilecache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrlsnchs%2Ffilecache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gbrlsnchs","download_url":"https://codeload.github.com/gbrlsnchs/filecache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gbrlsnchs%2Ffilecache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274968651,"owners_count":25383116,"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-09-13T02:00:10.085Z","response_time":70,"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","context-aware","fast","file","in-memory","in-memory-caching","radix-tree"],"created_at":"2024-11-06T13:22:15.605Z","updated_at":"2025-09-13T13:27:59.111Z","avatar_url":"https://github.com/gbrlsnchs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# filecache (In-memory file caching using Go)\n[![Build Status](https://travis-ci.org/gbrlsnchs/filecache.svg?branch=master)](https://travis-ci.org/gbrlsnchs/filecache)\n[![Sourcegraph](https://sourcegraph.com/github.com/gbrlsnchs/filecache/-/badge.svg)](https://sourcegraph.com/github.com/gbrlsnchs/filecache?badge)\n[![GoDoc](https://godoc.org/github.com/gbrlsnchs/filecache?status.svg)](https://godoc.org/github.com/gbrlsnchs/filecache)\n[![Minimal Version](https://img.shields.io/badge/minimal%20version-go1.10%2B-5272b4.svg)](https://golang.org/doc/go1.10)\n\n## About\nThis package recursively walks through a directory and caches files that match a regexp into a [radix tree](https://en.wikipedia.org/wiki/Radix_tree).\n\nSince it spawns one goroutine for each file / directory lookup, it is also context-aware, enabling all the process to return earlier when the context is done.\n\n## Usage\nFull documentation [here](https://godoc.org/github.com/gbrlsnchs/filecache).\n\n### Installing\n#### Go 1.10\n`vgo get -u github.com/gbrlsnchs/filecache`\n#### Go 1.11 or after\n`go get -u github.com/gbrlsnchs/filecache`\n\n### Importing\n```go\nimport (\n\t// ...\n\n\t\"github.com/gbrlsnchs/filecache\"\n)\n```\n\n### Reading all files in a directory\n```go\nc, err := filecache.ReadDir(\"foobar\", \"\")\nif err != nil {\n\t// If err != nil, directory \"foobar\" doesn't exist, or maybe one of the files\n\t// inside this directory has been deleted during the reading.\n}\ntxt := c.Get(\"bazqux.txt\")\nlog.Print(txt)\n```\n\n### Reading specific files in a directory\n```go\nc, err := filecache.ReadDir(\"foobar\", `\\.sql$`)\nif err != nil {\n\t// ...\n}\nq := c.Get(\"bazqux.sql\")\nlog.Print(q)\nlog.Print(c.Len())  // amount of files cached\nlog.Print(c.Size()) // total size in bytes\n```\n\n### Lazy-reading a directory\n```go\nc := filecache.New(\"foobar\")\n\n// do stuff...\n\nif err := c.Load(`\\.log$`); err != nil {\n\t// ...\n}\n```\n\n### Setting a custom goroutine limit\nBy default, this package spawns goroutines for each file inside each directory.  \nCurrently, the limit of goroutines is the result of `runtime.NumCPU()`. However, it is possible to use a cache with a custom limit by using the method `SetSemaphoreSize`.\n```go\nc := filecache.New(\"foobar\")\nc.SetSemaphoreSize(100)\nif err := c.Load(`\\.log$`); err != nil {\n\t// ...\n}\n```\n\n## Contributing\n### How to help\n- For bugs and opinions, please [open an issue](https://github.com/gbrlsnchs/filecache/issues/new)\n- For pushing changes, please [open a pull request](https://github.com/gbrlsnchs/filecache/compare)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbrlsnchs%2Ffilecache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgbrlsnchs%2Ffilecache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgbrlsnchs%2Ffilecache/lists"}