Skip to content

Commit

Permalink
v1.4.1
Browse files Browse the repository at this point in the history
Adding namespace and PSS-4 support.
  • Loading branch information
gilbitron committed Jul 15, 2014
1 parent f2ee011 commit eb43b12
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ The PHP SimpleCache Class is an easy way to cache 3rd party API calls.

## Install

You can either download the class manually and "require":

```php
require('SimpleCache.php');
```

or you can install via [composer](https://getcomposer.org):
Install via [composer](https://getcomposer.org):

```javascript
{
Expand All @@ -20,22 +14,27 @@ or you can install via [composer](https://getcomposer.org):
}
```

Run `composer install` then use as normal:

```php
require 'vendor/autoload.php';
$cache = new Gilbitron\Util\SimpleCache();
```

## Usage

A very basic usage example:

```php
require('SimpleCache.php');
$cache = new SimpleCache();
$cache = new Gilbitron\Util\SimpleCache();
$latest_tweet = $cache->get_data('tweet', 'http://search.twitter.com/search.atom?q=from:gilbitron&rpp=1');
echo $latest_tweet;
```

A more advanced example:

```php
require('SimpleCache.php');
$cache = new SimpleCache();
$cache = new Gilbitron\Util\SimpleCache();
$cache->cache_path = 'cache/';
$cache->cache_time = 3600;

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"php": ">=5.3.0"
},
"autoload": {
"files" : [
"simpleCache.php"
]
"psr-4": {
"Gilbitron\\Util\\": "src/"
}
}
}
8 changes: 5 additions & 3 deletions SimpleCache.php → src/SimpleCache.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php

namespace Gilbitron\Util;

/*
* SimpleCache v1.4.0
* SimpleCache v1.4.1
*
* By Gilbert Pellegrom
* http://dev7studios.com
*
* Free to use and abuse under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*/

class SimpleCache {

// Path to cache folder (with trailing /)
Expand Down Expand Up @@ -38,7 +40,7 @@ public function set_cache($label, $data)
public function get_cache($label)
{
if($this->is_cached($label)){
$filename = $this->cache_path . $this->safe_filename($label) . $this->cache_extension;
$filename = $this->cache_path . $this->safe_filename($label) . $this->cache_extension;
return file_get_contents($filename);
}

Expand Down

0 comments on commit eb43b12

Please sign in to comment.