Jamm\Memory\RedisObject::read PHP Method

read() public method

Read data from memory storage
public read ( string | array $key, mixed &$ttl_left ) : mixed
$key string | array (string or array of string keys)
$ttl_left mixed = (ttl - time()) of key. Use to exclude dog-pile effect, with lock/unlock_key methods.
return mixed
    public function read($key, &$ttl_left = -1)
    {
        if (is_array($key)) {
            $data = array();
            $return_ttl = $ttl_left !== -1 ? true : false;
            $ttl_left = array();
            foreach ($key as $arr_key) {
                $arr_key = (string) $arr_key;
                if ($return_ttl) {
                    $data[$arr_key] = $this->read_value($arr_key, $arr_key_ttl_left);
                    $ttl_left[$arr_key] = $arr_key_ttl_left;
                } else {
                    $data[$arr_key] = $this->read_value($arr_key);
                }
                if ($data[$arr_key] === false || $data[$arr_key] === null) {
                    unset($data[$arr_key]);
                    continue;
                }
            }
            return $data;
        } else {
            return $this->read_value($key, $ttl_left);
        }
    }