Skip to content

Commit 13f061f

Browse files
committed
add README.md
1 parent 4875d82 commit 13f061f

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## usage
2+
3+
- `composer require eecjimmy/basic`
4+
5+
```php
6+
namespace demo;
7+
use eecjimmy\Basic\CacheableTrait;
8+
class Demo
9+
{
10+
11+
use CacheableTrait;
12+
13+
public function getUser()
14+
{
15+
return $this->cacheGet(__METHOD__, function () {
16+
echo "cache missing...\n";
17+
return 'user';
18+
});
19+
}
20+
21+
public static function getStudent()
22+
{
23+
return self::cacheGetStatic(__METHOD__, function () {
24+
echo "cache missing...\n";
25+
return 'student';
26+
});
27+
}
28+
29+
public function getWithArgument($a)
30+
{
31+
$key = md5(__METHOD__ . json_encode(func_get_args()));
32+
return $this->cacheGet($key, function () {
33+
echo "cache missing...\n";
34+
return 'with-argument';
35+
});
36+
}
37+
}
38+
```

0 commit comments

Comments
 (0)