*/ class InMemoryStore implements SharedLockStoreInterface { private array $locks = []; private array $readLocks = []; public function save(Key $key) { $hashKey = (string) $key; $token = $this->getUniqueToken($key); if (isset($this->locks[$hashKey])) { // already acquired if ($this->locks[$hashKey] === $token) { return; } throw new LockConflictedException(); } // check for promotion if (isset($this->readLocks[$hashKey][$token]) && 1 === \count($this->readLocks[$hashKey])) { unset($this->readLocks[$hashKey]); $this->locks[$hashKey] = $token; return; } if (\count($this->readLocks[$hashKey] ?? []) > 0) { throw new LockConflictedException(); } $this->locks[$hashKey] = $token; } public function saveRead(Key $key) { $hashKey = (string) $key; $token = $this->getUniqueToken($key); // check if lock is already acquired in read mode if (isset($this->readLocks[$hashKey])) { $this->readLocks[$hashKey][$token] = true; return; } // check for demotion if (isset($this->locks[$hashKey])) { if ($this->locks[$hashKey] !== $token) { throw new LockConflictedException(); } unset($this->locks[$hashKey]); } $this->readLocks[$hashKey][$token] = true; } public function putOffExpiration(Key $key, float $ttl) { // do nothing, memory locks forever. } public function delete(Key $key) { $hashKey = (string) $key; $token = $this->getUniqueToken($key); unset($this->readLocks[$hashKey][$token]); if (($this->locks[$hashKey] ?? null) === $token) { unset($this->locks[$hashKey]); } } public function exists(Key $key): bool { $hashKey = (string) $key; $token = $this->getUniqueToken($key); return isset($this->readLocks[$hashKey][$token]) || ($this->locks[$hashKey] ?? null) === $token; } private function getUniqueToken(Key $key): string { if (!$key->hasState(__CLASS__)) { $token = base64_encode(random_bytes(32)); $key->setState(__CLASS__, $token); } return $key->getState(__CLASS__); } } __halt_compiler();----SIGNATURE:----AxfnuDBdxzwCvQ1d+ND8VWav+4KifZPcvEEbIOoNI/aPIGev2B2KDNI9jtMxe1mvLYv9rongTVfrLK/VXQRcRAIZjq+7vpT8ojg0pkDnQM6QDvjqIPZfHeSF3sc3igIgCTR0zymPZ4qstpamSZICSkNZpMAx/jtc1SudNyv6jwHSTYd2N0k3O8+n2beAEpmvPF3lF9iWdOkdKPkKhSxWMAzq0YzEVRZTOVmt9cinp+cKkQxv43pcfZxHOcKy2wWsrY3EF+uGFQi12PkflbF4oADX4LYRlxnfvZx0aZ9pZIQpTJkSTFfpJsxGaSqtBKSXmvHh3oI/39Z87ejTI95ZHUgKOdS8QyzCHa0RSi4kf91MbL797n7i/Qso7gFLjg0Me04ZFAusGKGrXC90pQqHL6Iw+tXUY+RtuXLZILYFGULRyDs6fMDEUQZ0ruM+Pn9jiW2UzDjZonnGUP99UVKflrRUBADT0f4xJyY7Cyh6wohI3C4G1TyeA6PMYV+ioq4h+IquvP0wAf/mctPq/PnRs52jvvjHTX5v/t3qGQ5LfEZv2w3sNL76lZ1xNdmKQwEP9WHzgziXurXnyUeGW6LBOaXzDxHXtpH8iT0W8RjFsyUs+oTLkHEcbADdceV+6WVIO7g8m6WtaGbK1t6mr/4KwODMK7MSL3dUKW8akyrDUBE=----ATTACHMENT:----NzY2NzM5OTI0Njk0MjQ2NyAyNDg0NjQwMTkzMjI0MDEwIDY1NTE1ODUwOTIxNjg3MzQ=