Skip to content

Commit 3da39ec

Browse files
authored
Remove calls to APC_* methods (#51010)
APC has been deprecated since PHP 7, and no longer even compiles for PHP 8.x Removes the usage of apc_* functions and the need to check which version of the functions to call.
1 parent fd9fa89 commit 3da39ec

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

src/Illuminate/Cache/ApcWrapper.php

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,6 @@
44

55
class ApcWrapper
66
{
7-
/**
8-
* Indicates if APCu is supported.
9-
*
10-
* @var bool
11-
*/
12-
protected $apcu = false;
13-
14-
/**
15-
* Create a new APC wrapper instance.
16-
*
17-
* @return void
18-
*/
19-
public function __construct()
20-
{
21-
$this->apcu = function_exists('apcu_fetch');
22-
}
23-
247
/**
258
* Get an item from the cache.
269
*
@@ -29,7 +12,7 @@ public function __construct()
2912
*/
3013
public function get($key)
3114
{
32-
$fetchedValue = $this->apcu ? apcu_fetch($key, $success) : apc_fetch($key, $success);
15+
$fetchedValue = apcu_fetch($key, $success);
3316

3417
return $success ? $fetchedValue : null;
3518
}
@@ -44,7 +27,7 @@ public function get($key)
4427
*/
4528
public function put($key, $value, $seconds)
4629
{
47-
return $this->apcu ? apcu_store($key, $value, $seconds) : apc_store($key, $value, $seconds);
30+
return apcu_store($key, $value, $seconds);
4831
}
4932

5033
/**
@@ -56,7 +39,7 @@ public function put($key, $value, $seconds)
5639
*/
5740
public function increment($key, $value)
5841
{
59-
return $this->apcu ? apcu_inc($key, $value) : apc_inc($key, $value);
42+
return apcu_inc($key, $value);
6043
}
6144

6245
/**
@@ -68,7 +51,7 @@ public function increment($key, $value)
6851
*/
6952
public function decrement($key, $value)
7053
{
71-
return $this->apcu ? apcu_dec($key, $value) : apc_dec($key, $value);
54+
return apcu_dec($key, $value);
7255
}
7356

7457
/**
@@ -79,7 +62,7 @@ public function decrement($key, $value)
7962
*/
8063
public function delete($key)
8164
{
82-
return $this->apcu ? apcu_delete($key) : apc_delete($key);
65+
return apcu_delete($key);
8366
}
8467

8568
/**
@@ -89,6 +72,6 @@ public function delete($key)
8972
*/
9073
public function flush()
9174
{
92-
return $this->apcu ? apcu_clear_cache() : apc_clear_cache('user');
75+
return apcu_clear_cache();
9376
}
9477
}

0 commit comments

Comments
 (0)