PHPackages                             pulpmedia/pulpcache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. pulpmedia/pulpcache

ActiveLibrary[Caching](/categories/caching)

pulpmedia/pulpcache
===================

A simple Cache class

14PHP

Since Sep 17Pushed 10y ago3 watchersCompare

[ Source](https://github.com/Pulpmedia/pulpCache)[ Packagist](https://packagist.org/packages/pulpmedia/pulpcache)[ RSS](/packages/pulpmedia-pulpcache/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

\#pulpCache

A simple Cache class

---

\##Usage

\###Initialization

To initialize a new Cache, simply create a new Instance of `PulpCache`

```
$cache = new pulpCache();

```

There are a few options you can add as an array:

```
cache_dir: Target directory for the cache (default ./cache)
config_file: Name of the Cache Configfile (defailt config.json)
expire_at: TimeStamp at which the Cache will be marked as old next (will be overwritten with each "save")
cache_name: Name of the Current cached file
ttl: Time to live (in Seconds). This will be used to set "expire_at" (current time + ttl). Default: 86500 (One Day)

```

\#####Example &lt;?php

```
require_once(dirname(__FILE)) . 'pulpcache/pulpCache.php');

$config = new array('cache_dir' => '/path/to/cache/dir',
					 'cache_name' => 'file_to_cache',
					 'ttl' => 3600
					);
$cache = new PulpCache($config);

```

\###Caching

To actually cache Content, there are 3 methods you should use:

```
hasCache() : Returns true if there is cached content available
getCache(): Returns the cached Content
saveCache($content): Saves $content

```

\#####Example

```
