{"id":15458020,"url":"https://github.com/websoftwares/cache","last_synced_at":"2025-09-11T23:19:05.275Z","repository":{"id":7828200,"uuid":"9199371","full_name":"websoftwares/Cache","owner":"websoftwares","description":"Yet another caching implementation.","archived":false,"fork":false,"pushed_at":"2013-04-06T07:38:03.000Z","size":184,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-12T13:19:17.724Z","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/websoftwares.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":"2013-04-03T16:27:56.000Z","updated_at":"2019-08-13T15:18:44.000Z","dependencies_parsed_at":"2022-08-28T04:22:56.249Z","dependency_job_id":null,"html_url":"https://github.com/websoftwares/Cache","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/websoftwares/Cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websoftwares%2FCache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websoftwares%2FCache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websoftwares%2FCache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websoftwares%2FCache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/websoftwares","download_url":"https://codeload.github.com/websoftwares/Cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websoftwares%2FCache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269355406,"owners_count":24403433,"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-08-08T02:00:09.200Z","response_time":72,"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":[],"created_at":"2024-10-01T22:57:24.619Z","updated_at":"2025-08-08T02:40:55.247Z","avatar_url":"https://github.com/websoftwares.png","language":"PHP","readme":"# Cache\n\nYet another caching implementation.\n\n[![Build Status](https://api.travis-ci.org/websoftwares/Cache.png)](https://travis-ci.org/websoftwares/Cache)\n\n## Usage\n\nBasic usage applies to all cache storage options\n\n```php\nuse Websoftwares\\Cache, Websoftwares\\Storage\\File;\n\n$cache = Cache::storage(new File());\n\n$cache-\u003esave('key',[\"a\",\"b\",\"c\"]);\n\n// Retrieve the cache\n\n$cache-\u003eget('key');\n\n```\n## Storage\n\nAvailable storage options:\n\n*   Apc (saves the cache to apc)\n*   File (saves the cache to a file)\n*   Memcache (save the cache to a memcache instance)\n*   Memcached (save the cache to a memcached instance)\n*   MongoDB (save the cache to a mongo instance)\n*   Redis (save the cache to a redis instance)\n*   Riak (save the cache to a riak instance)\n\n## Apc\n\n```php\nuse Websoftwares\\Cache, Websoftwares\\Storage\\Apc;\n\n$apc = Cache::storage(new Apc())\n -\u003esetExpiration(86400);\n\n$apc-\u003esave('key',[\"a\",\"b\",\"c\"]);\n\n// Retrieve the cache\n\n$apc-\u003eget('key');\n\n```\n\n## File\n\n```php\nuse Websoftwares\\Cache, Websoftwares\\Storage\\File;\n\n$cache = Cache::storage(new File())\n -\u003esetPath('/super/spot')\n -\u003esetExpiration(86400);\n\n$cache-\u003esave('key',[\"a\",\"b\",\"c\"]);\n\n// Retrieve the cache\n\n$cache-\u003eget('key');\n\n```\n\n## Memcache\n\nThis requires u have the PHP memcache extension installed.\n\non Debian/Ubuntu systems for example install like this (requires administrative password).\n\n```\nsudo apt-get install php5-memcache\n\n```\n\n```php\nuse Websoftwares\\Cache, Websoftwares\\Storage\\Memcache;\n\n$memcache = Cache::storage(new Memcache())\n    -\u003esetConnection(function() {\n        $instance = new \\Memcache;\n        $instance-\u003econnect('localhost','11211');\n        return $instance;\n    })\n    -\u003esetExpiration(86400);\n\n$memcache-\u003esave('key',[\"a\",\"b\",\"c\"]);\n\n// Retrieve the cache\n\n$memcache-\u003eget('key');\n\n```\n\n## Memcached\n\nThis requires u have the PHP memcached extension installed.\n\non Debian/Ubuntu systems for example install like this (requires administrative password).\n\n```\nsudo apt-get install php5-memcached\n\n```\n\n```php\nuse Websoftwares\\Cache, Websoftwares\\Storage\\Memcached;\n\n$memcached = Cache::storage(new Memcached())\n    -\u003esetConnection(function() {\n        $instance = new \\Memcached();\n        $instance-\u003eaddServer(\"localhost\", 11211);\n        return $instance;\n    })\n    -\u003esetExpiration(86400);\n\n$memcached-\u003esave('key',[\"a\",\"b\",\"c\"]);\n\n// Retrieve the cache\n\n$memcached-\u003eget('key');\n\n```\n\n## Mongo\nThis storage option makes use of the \"ensureIndex\" method option \"expireAfterSeconds\".\n\nThis option can only be used if the following requirements are met.\n\nRequirements:\n*   Latest PHP Mongo extension installed\n*   mongoDB deamon version 2.2+ | [read more](http://docs.mongodb.org/manual/tutorial/expire-data/ \"More information\")\n\nOn debian/ubuntu systems run the following command to install the mongo extension (requires administrator password).\n\n```\nsudo pecl install mongo\n```\n\n```php\nuse Websoftwares\\Cache, Websoftwares\\Storage\\Mongo;\n\n$mongo = Cache::storage(new Mongo())\n    -\u003esetConnection(function() {\n        $m = new \\MongoClient();\n        $db = $m-\u003emongocache;\n        return $db;\n    })\n    -\u003esetCollection('test')\n    -\u003esetExpiration(86400);\n\n$mongo-\u003esave('key',[\"a\",\"b\",\"c\"]);\n\n// Retrieve the cache\n\n$mongo-\u003eget('key');\n\n```\n\n## Redis\n\nThis requires u have the PHP [Predis](https://github.com/nrk/predis \"Predis\") package installed.\n\n```php\nuse Websoftwares\\Cache, Websoftwares\\Storage\\Redis;\n\n$redis = Cache::storage(new Redis())\n    -\u003esetConnection(function() {\n        $client = new \\Predis\\Client([\n            'scheme'   =\u003e 'tcp',\n            'host'     =\u003e '127.0.0.1',\n            'port'     =\u003e 6379,\n        ]);\n        return $client;\n    })\n    -\u003esetExpiration(86400);\n\n$redis-\u003esave('key',[\"a\",\"b\",\"c\"]);\n\n// Retrieve the cache\n\n$redis-\u003eget('key');\n\n```\n\n## Riak\n\nThis requires u have the PHP [Riak](https://github.com/basho/riak-php-client \"Riak\") official package installed.\n\n```php\nuse Websoftwares\\Cache, Websoftwares\\Storage\\Riak;\n\n$riak = Cache::storage(new Riak())\n    -\u003esetConnection(function() {\n        $client = new \\Basho\\Riak\\Riak('127.0.0.1', 8098);\n        return $client;\n    })\n    -\u003esetBucket('testBucket')\n    -\u003esetExpiration(86400);\n\n$riak-\u003esave('key',[\"a\",\"b\",\"c\"]);\n\n// Retrieve the cache\n\n$riak-\u003eget('key');\n\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebsoftwares%2Fcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebsoftwares%2Fcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebsoftwares%2Fcache/lists"}