Airship\Engine\Cache\SharedMemory::get PHP Method

get() public method

Get a cache entry
public get ( string $key ) : null | mixed
$key string
return null | mixed
    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);
    }