Repository navigation
Expand file tree
/
Copy pathCache.php
More file actions
executable file
·93 lines (85 loc) · 2.63 KB
/
Copy pathCache.php
File metadata and controls
executable file
·93 lines (85 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Webiny Framework (http://www.webiny.com/framework)
*
* @copyright Copyright Webiny LTD
*/
namespace Webiny\Component\Cache;
use Webiny\Component\StdLib\ComponentTrait;
/**
* Webiny cache component.
*
* The cache component is used to store different information into memory or file system for much faster access.
* The stored information can only be accessed for a limited time, after which it is invalidated.
*
*
* The Memory library is required by this class.
*
* @package Webiny\Component\Cache
*/
class Cache
{
use ComponentTrait;
/**
* Create a cache instance with APC as cache driver.
*
* @param array $options Cache options.
*
* @return CacheStorage
*/
public static function APC(array $options = [])
{
return new CacheStorage(Storage\APC::getInstance(), $options);
}
/**
* Create a cache instance with Couchbase as cache driver.
*
* @param string $user Couchbase username.
* @param string $password Couchbase password.
* @param string $bucket Couchbase bucket.
* @param string $host Couchbase host (with port number).
* @param array $options Cache options.
*
* @return CacheStorage
*/
public static function Couchbase($user, $password, $bucket, $host = '127.0.0.1:8091', $options = [])
{
return new CacheStorage(Storage\Couchbase::getInstance($user, $password, $bucket, $host), $options);
}
/**
* Create a cache instance with Memcache as cache driver.
*
* @param string $host Host where the memcached is running.
* @param int $port Port where memcached is running.
* @param array $options Cache options.
*
* @return CacheStorage
*/
public static function Memcache($host = '127.0.0.1', $port = 11211, $options = [])
{
return new CacheStorage(Storage\Memcache::getInstance($host, $port), $options);
}
/**
* Create a cache instance with Redis as cache driver.
*
* @param string $host Host where the Redis server is running.
* @param int $port Port where Redis server is running.
* @param array $options Cache options.
*
* @return CacheStorage
*/
public static function Redis($host = '127.0.0.1', $port = 6379, $options = [])
{
return new CacheStorage(Storage\Redis::getInstance($host, $port), $options);
}
/**
* Create a cache instance with Null cache driver.
* NOTE: Null driver turns off the cache.
*
* @return CacheStorage
*/
public static function Null()
{
return new CacheStorage(new Storage\Null());
}
}