Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
rcastera committed Sep 21, 2013
1 parent f34500f commit b032a02
Showing 1 changed file with 54 additions and 23 deletions.
77 changes: 54 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,71 @@
ApcCache
=============

The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provide a
free, open, and robust framework for caching and optimizing PHP intermediate code. This class is in
simple form, an Abstraction to the APC Library.
The Alternative PHP Cache ([APC](http://www.php.net/manual/en/book.apc.php)) is a free and open opcode cache for PHP.
Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code. This class
is in simple form, an Abstraction to the APC Library.


## Setup ##

Add a `composer.json` file to your project:

```javascript
{
"require": {
"rcastera/apc": "v1.0.0"
}
}
```

Then provided you have [composer](http://getcomposer.org) installed, you can run the following command:

```bash
$ composer.phar install
```

That will fetch the library and its dependencies inside your vendor folder. Then you can add the following to your
.php files in order to use the library

```php
require 'vendor/autoload.php';
```

Then you need to `use` the relevant class, for example:

```php
use rcastera\Apc\ApcCache;
```

Example
-----------
<?php
require 'vendor/autoload.php';

use rcastera\Apc\ApcCache;
```php
require 'vendor/autoload.php';

// Create a new object with properties to store in cache.
$object = new stdClass;
$object->name = 'Richard';
$object->age = 30;
use rcastera\Apc\ApcCache;

// Store the object in cache.
ApcCache::store('rich', $object, 3600);
// Create a new object with properties to store in cache.
$object = new stdClass;
$object->name = 'Richard';
$object->age = 30;

// Now check if it exists and fetch it.
if (ApcCache::exists('rich')) {
$person = ApcCache::fetch('rich');
}
// Store the object in cache.
ApcCache::store('rich', $object, 3600);

// Output the name property value.
echo $person->name;
// Now check if it exists and fetch it.
if (ApcCache::exists('rich')) {
$person = ApcCache::fetch('rich');
}

// Delete this specific key in cache.
ApcCache::delete('rich');
// Output the name property value.
echo $person->name;

// Delete all cache.
ApcCache::clear();
// Delete this specific key in cache.
ApcCache::delete('rich');

// Delete all cache.
ApcCache::clear();
```


Contributing
Expand Down

0 comments on commit b032a02

Please sign in to comment.