{"id":19947489,"url":"https://github.com/lefuturiste/localstorage","last_synced_at":"2025-05-03T18:30:44.016Z","repository":{"id":57013573,"uuid":"156456483","full_name":"lefuturiste/localstorage","owner":"lefuturiste","description":"A simple library to do key:value storage like redis directly with PHP","archived":false,"fork":false,"pushed_at":"2022-05-03T08:01:51.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-28T13:38:57.997Z","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/lefuturiste.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":"2018-11-06T22:25:32.000Z","updated_at":"2023-08-22T00:12:40.000Z","dependencies_parsed_at":"2022-08-21T14:50:32.917Z","dependency_job_id":null,"html_url":"https://github.com/lefuturiste/localstorage","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lefuturiste%2Flocalstorage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lefuturiste%2Flocalstorage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lefuturiste%2Flocalstorage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lefuturiste%2Flocalstorage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lefuturiste","download_url":"https://codeload.github.com/lefuturiste/localstorage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224370246,"owners_count":17299968,"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-13T00:36:14.499Z","updated_at":"2024-11-13T00:36:15.050Z","avatar_url":"https://github.com/lefuturiste.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Local storage\n\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Flefuturiste%2Flocalstorage%2Fbadge\u0026style=for-the-badge)](https://actions-badge.atrox.dev/lefuturiste/localstorage/goto)\n\nThis library can be useful if you need localstorage/cache key:value on disk for your PHP application.\n\n## Installation\n\nYou can easily install the localstorage lib using composer:\n\n`composer require lefuturiste/localstorage`\n\n## Usage\n\nAll methods are on the Lefuturiste\\LocalStorage\\LocalStorage class\n\nThis is a small and quick example of this lib.\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\n// simple key value store\n$localStorage = new Lefuturiste\\LocalStorage\\LocalStorage();\n$localStorage-\u003eset('my-key', 'my-value'); // set a value\n$localStorage-\u003eset('my-key', ['object' =\u003e ['is_complex' =\u003e true, 'number' =\u003e 1]]); // all values are json encoded so you can save array with string, int, float, boolean and null values\n$localStorage-\u003esave(); // this will write the file on disk, don't forget to call it when you mutate the state!\n$localStorage-\u003eget('my-key'); // retrieve the value (this will decode the JSON)\n$localStorage-\u003ehas('my-key'); // will return true\n$localStorage-\u003ehas('unknown-key'); // will return false\n$localStorage-\u003edel('my-key'); // yes it does what you think it will do\n$localStorage-\u003eclear(); // you can remove all the keys using the clear() method\n$localStorage-\u003eunlinkStorage(); // you can complety remove the .json file on the disk\n\n// duration management\n// by default all the keys are saved with the date of the creating, so you can if you want, delete all the keys olden than a specified duration.\n$localStorage-\u003edeleteOlderThan(\\Carbon\\CarbonInterval::seconds(10));\n```\n\n## Tests\n\nAll the tests are in the test folder\n\n`vendor/bin/phpunit test`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flefuturiste%2Flocalstorage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flefuturiste%2Flocalstorage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flefuturiste%2Flocalstorage/lists"}