IpCacheContext.php in Drupal 10
File
core/lib/Drupal/Core/Cache/Context/IpCacheContext.php
View source
<?php
namespace Drupal\Core\Cache\Context;
use Drupal\Core\Cache\CacheableMetadata;
class IpCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
public static function getLabel() {
return t('IP address');
}
public function getContext() {
return $this->requestStack
->getCurrentRequest()
->getClientIp();
}
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}
Classes
Name |
Description |
IpCacheContext |
Defines the IpCacheContext service, for "per IP address" caching. |