{"id":20678875,"url":"https://github.com/phpgt/filecache","last_synced_at":"2025-04-13T18:35:12.946Z","repository":{"id":44348826,"uuid":"511182258","full_name":"phpgt/FileCache","owner":"phpgt","description":"Cache data in local files.","archived":false,"fork":false,"pushed_at":"2025-03-07T15:59:08.000Z","size":83,"stargazers_count":0,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T06:00:02.877Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/phpgt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["phpgt"]}},"created_at":"2022-07-06T14:59:32.000Z","updated_at":"2025-03-07T15:58:00.000Z","dependencies_parsed_at":"2025-01-17T15:15:41.114Z","dependency_job_id":"86f2f41b-93de-495a-83c6-69fdc4ac1f15","html_url":"https://github.com/phpgt/FileCache","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"85c795daced5fa3d84c947dbf5c7e84bbe34c039"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpgt%2FFileCache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpgt%2FFileCache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpgt%2FFileCache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpgt%2FFileCache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpgt","download_url":"https://codeload.github.com/phpgt/FileCache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248761294,"owners_count":21157529,"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":[],"created_at":"2024-11-16T21:22:53.302Z","updated_at":"2025-04-13T18:35:12.919Z","avatar_url":"https://github.com/phpgt.png","language":"PHP","funding_links":["https://github.com/sponsors/phpgt"],"categories":[],"sub_categories":[],"readme":"Cache data in local files.\n==========================\n\nMaking expensive operations like HTTP calls or database queries can be minimised by caching the result of the operations in local files. This can improve performance, reduce network usage, and avoid rate limiting, to name some common benefits. This library provides a single function to define where to cache, what to cache, and when to cache. A validity of 1 hour is set by default, if the valid time is not specified.\n\n***\n\n\u003ca href=\"https://github.com/PhpGt/FileCache/actions\" target=\"_blank\"\u003e\n\t\u003cimg src=\"https://badge.status.php.gt/filecache-build.svg\" alt=\"Build status\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://app.codacy.com/gh/PhpGt/FileCache\" target=\"_blank\"\u003e\n\t\u003cimg src=\"https://badge.status.php.gt/filecache-quality.svg\" alt=\"Code quality\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://app.codecov.io/gh/PhpGt/FileCache\" target=\"_blank\"\u003e\n\t\u003cimg src=\"https://badge.status.php.gt/filecache-coverage.svg\" alt=\"Code coverage\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/PhpGt/FileCache\" target=\"_blank\"\u003e\n\t\u003cimg src=\"https://badge.status.php.gt/filecache-version.svg\" alt=\"Current version\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"http://www.php.gt/filecache\" target=\"_blank\"\u003e\n\t\u003cimg src=\"https://badge.status.php.gt/filecache-docs.svg\" alt=\"PHP.Gt/FileCache documentation\" /\u003e\n\u003c/a\u003e\n\n## Example usage: get the latitude/longitude of the user's IP address\n\nIt's an expensive operation to make an HTTP call for every page view, but in this example we want to use a remote service to provide us with the estimated latitude/longitude of the current IP address.\n\nThe first time we see the IP address will have to make an HTTP call, but subsequent calls will be able to take advantage of the cache.\n\n```php\n$ipAddress = $_SERVER[\"REMOTE_ADDR\"];\n$fileCache = new Gt\\FileCache\\Cache(\"/tmp/ip-address-geolocation\");\n\n// This function uses file_get_contents to contact the remote server\n// at ipinfo.io, a costly operation. We will pass the lookup function\n// into the cache, so it is only called when we don't have a fresh result.\n$lookup = function()use($ipAddress):string {\n\t$jsonString = file_get_contents(\"https://ipinfo.io/$ipAddress\");\n\t$obj = json_decode($jsonString);\n\treturn $obj-\u003eloc;\n}\n\n$location = $fileCache-\u003eget(\"lat-lon\", $lookup);\necho \"Your location is: $location\";\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpgt%2Ffilecache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpgt%2Ffilecache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpgt%2Ffilecache/lists"}