From 13ed8ad335b9122ad89c0d4d6fa1c26aa9721858 Mon Sep 17 00:00:00 2001 From: Felix Date: Wed, 22 Mar 2017 11:36:19 +0700 Subject: [PATCH] Update Readme --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a48097..748c19c 100644 --- a/README.md +++ b/README.md @@ -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); + } + +} +```