{"id":21771132,"url":"https://github.com/initphp/cache","last_synced_at":"2025-03-21T06:22:11.573Z","repository":{"id":56991530,"uuid":"470091262","full_name":"InitPHP/Cache","owner":"InitPHP","description":"PSR-16 is a simple caching library that uses the Simple Cache interface.","archived":false,"fork":false,"pushed_at":"2022-03-17T08:22:54.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T03:13:45.647Z","etag":null,"topics":["cache","file-cache","memcache","memcached","pdo-cache","php","psr-16","redis","redis-cache","simple-cache","wincache"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/InitPHP.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-03-15T09:38:13.000Z","updated_at":"2023-10-06T04:23:52.000Z","dependencies_parsed_at":"2022-08-21T10:10:40.099Z","dependency_job_id":null,"html_url":"https://github.com/InitPHP/Cache","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FCache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FCache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FCache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FCache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InitPHP","download_url":"https://codeload.github.com/InitPHP/Cache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244746789,"owners_count":20503264,"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":["cache","file-cache","memcache","memcached","pdo-cache","php","psr-16","redis","redis-cache","simple-cache","wincache"],"created_at":"2024-11-26T14:15:10.232Z","updated_at":"2025-03-21T06:22:11.548Z","avatar_url":"https://github.com/InitPHP.png","language":"PHP","readme":"# InitPHP Cache\n\nPSR-16 is a simple caching library that uses the Simple Cache interface.\n\n[![Latest Stable Version](http://poser.pugx.org/initphp/cache/v)](https://packagist.org/packages/initphp/cache) [![Total Downloads](http://poser.pugx.org/initphp/cache/downloads)](https://packagist.org/packages/initphp/cache) [![Latest Unstable Version](http://poser.pugx.org/initphp/cache/v/unstable)](https://packagist.org/packages/initphp/cache) [![License](http://poser.pugx.org/initphp/cache/license)](https://packagist.org/packages/initphp/cache) [![PHP Version Require](http://poser.pugx.org/initphp/cache/require/php)](https://packagist.org/packages/initphp/cache)\n\n## Requirements\n\n- PHP 5.6 or higher\n- [PSR-16 Simple Cache Interface](https://www.php-fig.org/psr/psr-16/)\n\nDepending on the handler you will use, it may need PHP extensions.\n\n- Redis\n- PDO\n- Wincache\n- Memcache or Memcached\n\n## Installation\n\n```\ncomposer require initphp/cache\n```\n\n## Usage\n\n```php \nrequire_once \"../vendor/autoload.php\";\nuse \\InitPHP\\Cache\\Cache;\n\n$cache = Cache::create(\\InitPHP\\Cache\\Handler\\File::class, [\n    'path'      =\u003e __DIR__ . '/Cache/';\n]);\n\nif(($posts = $cache-\u003eget('posts', null)) === null){\n    $posts = [\n        ['id' =\u003e '12', 'title' =\u003e 'Post 12 Title', 'content' =\u003e 'Post 12 Content'],\n        ['id' =\u003e '15', 'title' =\u003e 'Post 15 Title', 'content' =\u003e 'Post 15 Content'],\n        ['id' =\u003e '18', 'title' =\u003e 'Post 18 Title', 'content' =\u003e 'Post 18 Content']\n    ];\n    $cache-\u003eset('posts', $posts, 120);\n}\n\necho '\u003cpre\u003e'; print_r($posts) echo '\u003c/pre\u003e';\n```\n\n## Configuration and Options\n\n### `\\InitPHP\\Cache\\Handler\\File::class`\n\n```php \n$options = [\n    'prefix'    =\u003e 'cache_',\n    'mode'      =\u003e 0640,\n];\n```\n\n### `\\InitPHP\\Cache\\Handler\\Memcache::class`\n\n```php \n$options = [\n    'prefix'    =\u003e 'cache_',\n    'host'          =\u003e '127.0.0.1',\n    'port'          =\u003e 11211,\n    'weight'        =\u003e 1,\n    'raw'           =\u003e false,\n    'default_ttl'   =\u003e 60,\n];\n```\n\n### `\\InitPHP\\Cache\\Handler\\PDO::class`\n\n```php \n$options = [\n    'prefix'    =\u003e 'cache_',\n    'dsn'           =\u003e 'mysql:host=localhost;dbname=test',\n    'username'      =\u003e null,\n    'password'      =\u003e null,\n    'charset'       =\u003e 'utf8mb4',\n    'collation'     =\u003e 'utf8mb4_general_ci',\n    'table'         =\u003e 'cache'\n];\n```\n\n_Below is a sample cache table creation query for MySQL._\n\n```sql \nCREATE TABLE `cache` (\n    `name` VARCHAR(255) NOT NULL,\n    `ttl` INT(11) NULL DEFAULT NULL,\n    `data` TEXT NOT NULL,\n    UNIQUE  (`name`)\n) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;\n```\n\n### `\\InitPHP\\Cache\\Handler\\Redis::class`\n\n```php \n$options = [\n    'prefix'    =\u003e 'cache_',\n    'host'      =\u003e '127.0.0.1',\n    'password'  =\u003e null,\n    'port'      =\u003e 6379,\n    'timeout'   =\u003e 0,\n    'database'  =\u003e 0\n];\n```\n\n### `\\InitPHP\\Cache\\Handler\\Wincache::class`\n\n```php \n$options = [\n    'prefix'    =\u003e 'cache_', // Cache Name Prefix\n    'default_ttl'   =\u003e 60, // Used if ttl is NULL or not specified.\n];\n```\n\n## Credits\n\n- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) \u003c\u003cinfo@muhammetsafak.com.tr\u003e\u003e\n\n## License\n\nCopyright \u0026copy; 2022 [MIT License](./LICENSE)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Fcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finitphp%2Fcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Fcache/lists"}