Skip to content

Commit c9ea8b8

Browse files
committed
Use __call
1 parent bd581dd commit c9ea8b8

File tree

4 files changed

+60
-27
lines changed

4 files changed

+60
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor/
22
.idea/
3+
index.php

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Cache standalone
2+
You can find the docs for the Illuminate cache here: [cache](https://laravel.com/docs/5.5/cache)
23

34
## Example
45
```php
@@ -22,3 +23,55 @@ $value = $cache->remember('users', 1, function () {
2223

2324
echo $value;
2425
```
26+
27+
## Drivers
28+
You can use different cache drivers. By setting this in the config variable.
29+
30+
### FileCache Driver
31+
```php
32+
$config = [
33+
'cache.default' => 'file',
34+
'cache.stores.file' => [
35+
'driver' => 'file',
36+
'path' => __DIR__ . '/cache'
37+
]
38+
];
39+
```
40+
41+
### RedisCache Driver (not tested)
42+
```php
43+
$config = [
44+
'cache.default' => 'redis',
45+
'cache.stores.redis' => [
46+
'driver' => 'redis',
47+
'connection' => 'default'
48+
],
49+
'cache.prefix' => 'illuminate_non_laravel',
50+
'database.redis' => [
51+
'cluster' => false,
52+
'default' => [
53+
'host' => '127.0.0.1',
54+
'port' => 6379,
55+
'database' => 0,
56+
],
57+
]
58+
];
59+
```
60+
61+
### MemeCache Driver (not tested)
62+
```Php
63+
$config = [
64+
'cache.default' => 'memcached',
65+
'cache.stores.memcached' => [
66+
'driver' => 'memcached',
67+
'servers' => [
68+
[
69+
'host' => '127.0.0.1',
70+
'port' => g11211,
71+
'weight' => 100,
72+
],
73+
],
74+
],
75+
'cache.prefix' => 'illuminate_non_laravel'
76+
];
77+
```

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"license": "MIT",
44
"authors": [
55
{
6-
"name": "larsvankleef",
7-
"email": "[email protected]"
6+
"name": "Lars van Kleef",
7+
"email": "[email protected]"
88
}
99
],
1010
"autoload": {
1111
"psr-4": {
12-
"stackkit\\cache-standalone\\": "src/"
12+
"Stackkit\\CacheStandalone\\": "src/"
1313
}
1414
},
1515
"require": {

src/Cache.php

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Stackkit\Cachestandalone;
3+
namespace Stackkit\CacheStandalone;
44

55
use Illuminate\Cache\CacheManager;
66
use Illuminate\Container\Container;
@@ -35,28 +35,7 @@ public function __construct($config)
3535
$this->cache = $this->cacheManager->store($config['cache.default']);
3636
}
3737

38-
public function put($name, $data, $time = 1)
39-
{
40-
return $this->cache->put($name, $data, $time);
41-
}
42-
43-
public function get($name, $function = null)
44-
{
45-
return $this->cache->get($name, $function);
46-
}
47-
48-
public function remember($name, $time = 1, $function = null)
49-
{
50-
return $this->cache->remember($name, $time, $function);
51-
}
52-
53-
public function forget($name)
54-
{
55-
return $this->cache->forget($name);
56-
}
57-
58-
public function flush()
59-
{
60-
return $this->cache->flush();
38+
public function __call($methode, $args) {
39+
return call_user_func_array([$this->cache, $methode], $args);
6140
}
6241
}

0 commit comments

Comments
 (0)