Skip to content

Commit

Permalink
Update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmaier1989 authored Mar 22, 2017
1 parent 3d7cc54 commit 13ed8ad
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# soft-cache
Soft cache for your class method
Soft cache for your class methods. Sometimes your PHP application runs the same method with the same arguments during the same code execution. Better caching the output of it, especially when queryin a databse or an API.

## Usage

```php
class TestClass {

use SoftCache\SoftCacheTrait;

public function getNextYearsWithCache($yearFrom, $years) {
if ($this->checkMethodCache(__FUNCTION__, func_get_args())) {
return $this->readMethodCache(__FUNCTION__, func_get_args());
}
$output = $this->getNextYearsWithoutCache($yearFrom, $years);
$this->writeMethodCache(__FUNCTION__, func_get_args(), $output);
return $output;
}

public function getNextYearsWithoutCache($yearFrom, $years) {
return range($yearFrom + 1 , $yearFrom + $years);
}

}
```

0 comments on commit 13ed8ad

Please sign in to comment.