ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
InMemoryRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
27{
29 public array $entries = [];
30
31 public int $reads = 0;
32
33 public int $bulk_reads = 0;
34
35 public int $has_calls = 0;
36
37 public int $writes = 0;
38
39 public function has(StorageNamespace $namespace, string $key): bool
40 {
41 $this->has_calls++;
42
43 return isset($this->entries[$namespace->value()][$key]);
44 }
45
46 public function read(StorageNamespace $namespace, string $key): ?string
47 {
48 $this->reads++;
49
50 return $this->entries[$namespace->value()][$key] ?? null;
51 }
52
53 public function readAll(StorageNamespace $namespace): array
54 {
55 $this->bulk_reads++;
56
57 return $this->entries[$namespace->value()] ?? [];
58 }
59
60 public function write(StorageNamespace $namespace, string $key, string $value): void
61 {
62 $this->writes++;
63 $this->entries[$namespace->value()][$key] = $value;
64 }
65
66 public function remove(StorageNamespace $namespace, string $key): void
67 {
68 unset($this->entries[$namespace->value()][$key]);
69 }
70
71 public function removeAll(StorageNamespace $namespace): void
72 {
73 unset($this->entries[$namespace->value()]);
74 }
75}
Isolates the keys of one consumer from every other consumer of a storage.
has(StorageNamespace $namespace, string $key)
read(StorageNamespace $namespace, string $key)
write(StorageNamespace $namespace, string $key, string $value)
readAll(StorageNamespace $namespace)
Every present entry of one namespace.
Persistence contract of one storage scope.
Definition: Repository.php:32