File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 5
5
use Memcached ;
6
6
use Carbon \Carbon ;
7
7
use Illuminate \Contracts \Cache \Store ;
8
+ use ReflectionMethod ;
8
9
9
10
class MemcachedStore extends TaggableStore implements Store
10
11
{
@@ -22,6 +23,13 @@ class MemcachedStore extends TaggableStore implements Store
22
23
*/
23
24
protected $ prefix ;
24
25
26
+ /**
27
+ * A flag indicating whether the Memcached version is >= 3.0.0
28
+ *
29
+ * @var bool
30
+ */
31
+ protected $ memcached_version_3_0 ;
32
+
25
33
/**
26
34
* Create a new Memcached store.
27
35
*
@@ -33,6 +41,7 @@ public function __construct($memcached, $prefix = '')
33
41
{
34
42
$ this ->setPrefix ($ prefix );
35
43
$ this ->memcached = $ memcached ;
44
+ $ this ->memcached_version_3_0 = (new ReflectionMethod ('Memcached ' , 'getMulti ' ))->getNumberOfParameters () == 2 ;
36
45
}
37
46
38
47
/**
@@ -64,7 +73,12 @@ public function many(array $keys)
64
73
return $ this ->prefix .$ key ;
65
74
}, $ keys );
66
75
67
- $ values = $ this ->memcached ->getMulti ($ prefixedKeys , null , Memcached::GET_PRESERVE_ORDER );
76
+ if ($ this ->memcached_version_3_0 ) {
77
+ $ values = $ this ->memcached ->getMulti ($ prefixedKeys , Memcached::GET_PRESERVE_ORDER );
78
+ } else {
79
+ $ null = null ;
80
+ $ values = $ this ->memcached ->getMulti ($ prefixedKeys , $ null , Memcached::GET_PRESERVE_ORDER );
81
+ }
68
82
69
83
if ($ this ->memcached ->getResultCode () != 0 ) {
70
84
return array_fill_keys ($ keys , null );
You can’t perform that action at this time.
0 commit comments