Skip to content

Commit

Permalink
Remove calls to APC_* methods (#51010)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
serpentblade authored Apr 10, 2024
1 parent fd9fa89 commit 3da39ec
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions src/Illuminate/Cache/ApcWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@

class ApcWrapper
{
/**
* Indicates if APCu is supported.
*
* @var bool
*/
protected $apcu = false;

/**
* Create a new APC wrapper instance.
*
* @return void
*/
public function __construct()
{
$this->apcu = function_exists('apcu_fetch');
}

/**
* Get an item from the cache.
*
Expand All @@ -29,7 +12,7 @@ public function __construct()
*/
public function get($key)
{
$fetchedValue = $this->apcu ? apcu_fetch($key, $success) : apc_fetch($key, $success);
$fetchedValue = apcu_fetch($key, $success);

return $success ? $fetchedValue : null;
}
Expand All @@ -44,7 +27,7 @@ public function get($key)
*/
public function put($key, $value, $seconds)
{
return $this->apcu ? apcu_store($key, $value, $seconds) : apc_store($key, $value, $seconds);
return apcu_store($key, $value, $seconds);
}

/**
Expand All @@ -56,7 +39,7 @@ public function put($key, $value, $seconds)
*/
public function increment($key, $value)
{
return $this->apcu ? apcu_inc($key, $value) : apc_inc($key, $value);
return apcu_inc($key, $value);
}

/**
Expand All @@ -68,7 +51,7 @@ public function increment($key, $value)
*/
public function decrement($key, $value)
{
return $this->apcu ? apcu_dec($key, $value) : apc_dec($key, $value);
return apcu_dec($key, $value);
}

/**
Expand All @@ -79,7 +62,7 @@ public function decrement($key, $value)
*/
public function delete($key)
{
return $this->apcu ? apcu_delete($key) : apc_delete($key);
return apcu_delete($key);
}

/**
Expand All @@ -89,6 +72,6 @@ public function delete($key)
*/
public function flush()
{
return $this->apcu ? apcu_clear_cache() : apc_clear_cache('user');
return apcu_clear_cache();
}
}

0 comments on commit 3da39ec

Please sign in to comment.