ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilShm.php
Go to the documentation of this file.
1 <?php
2 
26 {
27  protected static int $shm_id;
28  protected static int $block_size = 0;
29 
33  protected function getActive(): bool
34  {
35  return function_exists('shmop_open');
36  }
37 
41  protected function getInstallable(): bool
42  {
43  return false;
44  }
45 
49  public function __construct(string $service_id, string $component)
50  {
51  parent::__construct($service_id, $component);
52  self::$shm_id = shmop_open(0xff3, "c", 0644, 100);
53  self::$block_size = shmop_size(self::$shm_id);
54  }
55 
56  public function exists(string $key): bool
57  {
58  return shm_has_var(self::$shm_id, $key);
59  }
60 
61 
62  public function set(string $key, $serialized_value, int $ttl = null): bool
63  {
64  return (bool) shmop_write(self::$shm_id, $key, $serialized_value);
65  }
66 
67 
68  public function get(string $key)
69  {
70  return shmop_read(self::$shm_id, 0, self::$block_size);
71  }
72 
73  public function delete(string $key): bool
74  {
75  return shm_remove_var(self::$shm_id, $key);
76  }
77 
78  public function flush(bool $complete = false): bool
79  {
80  // currently a partial flushing is missing
81  shmop_delete(self::$shm_id);
82 
83  return true;
84  }
85 
89  public function serialize($value): string
90  {
91  return serialize($value);
92  }
93 
98  public function unserialize($serialized_value)
99  {
100  return unserialize($serialized_value);
101  }
102 }
unserialize($serialized_value)
Definition: class.ilShm.php:98
static int $block_size
Definition: class.ilShm.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(string $service_id, string $component)
ilShm constructor.
Definition: class.ilShm.php:49
getActive()
set self::$active
Definition: class.ilShm.php:33
string $key
Consumer key/client ID value.
Definition: System.php:193
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.ilShm.php:25
exists(string $key)
Definition: class.ilShm.php:56
getInstallable()
set self::$installable
Definition: class.ilShm.php:41
serialize($value)
Definition: class.ilShm.php:89
__construct(Container $dic, ilPlugin $plugin)
flush(bool $complete=false)
Definition: class.ilShm.php:78
static int $shm_id
Definition: class.ilShm.php:27