ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
BaseAdaptor.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Cache\Adaptor;
22
24
28abstract class BaseAdaptor implements Adaptor
29{
30 protected const LOCK_UNTIL = '_lock_until';
31 private string $instance_prefix;
32
33 public function __construct(protected Config $config)
34 {
35 // generates a unique prefix for the current instance. this is only to prevent collisions when running multiple
36 // ILIAS Instances on the same server. It uses the md5 hash of the current working directory and takes the first
37 // 6 characters. This is not a secure way to generate a prefix, but it is sufficient for this purpose.
38 // It's highly unlikely that two paths will result in the same prefix.
39 $this->instance_prefix = substr(md5(getcwd()), 0, 6);
40 }
41
42 protected function buildKey(string $container, string $key): string
43 {
44 return $this->buildContainerPrefix($container) . $key;
45 }
46
47 protected function buildContainerPrefix(string $container): string
48 {
49 return $this->instance_prefix . self::CONTAINER_PREFIX_SEPARATOR . $container . self::CONTAINER_PREFIX_SEPARATOR;
50 }
51}
__construct(protected Config $config)
Definition: BaseAdaptor.php:33
buildKey(string $container, string $key)
Definition: BaseAdaptor.php:42
buildContainerPrefix(string $container)
Definition: BaseAdaptor.php:47
$container
@noRector
Definition: wac.php:37