public function get(string $key)
{
$shmKey = $this->getSHMKey($key);
if (!\apcu_exists($shmKey)) {
return null;
}
$data = \apcu_fetch($shmKey);
if ($this->authKey) {
// We're authenticating this value:
$mac = Util::subString($data, 0, \Sodium\CRYPTO_GENERICHASH_BYTES_MAX);
$data = Util::subString($data, \Sodium\CRYPTO_GENERICHASH_BYTES_MAX);
if (!Symmetric::verify($data, $this->authKey, $mac, true)) {
// Someone messed with our shared memory.
throw new DataCorrupted();
}
}
return \json_decode($data, true);
}