src/Flintstone.php
public function get(string $key)
    {
        Validation::validateKey($key);

        // Fetch the key from cache
        if ($cache = $this->getConfig()->getCache()) {
            if ($cache->contains($key)) {
                return $cache->get($key);
            }
        }

        // Fetch the key from database
        $file = $this->getDatabase()->readFromFile();
        $data = false;

        foreach ($file as $line) {
            /** @var Line $line */
            if ($line->getKey() == $key) {
                $data = $this->decodeData($line->getData());
                break;
            }
        }

        // Save the data to cache
        if ($cache && $data !== false) {
            $cache->set($key, $data);
        }

        return $data;
    }
public function get(string $key)
    {
        Validation::validateKey($key);

        // Fetch the key from cache
        if ($cache = $this->getConfig()->getCache()) {
            if ($cache->contains($key)) {
                return $cache->get($key);
            }
        }

        // Fetch the key from database
        $file = $this->getDatabase()->readFromFile();
        $data = false;

        foreach ($file as $line) {
            /** @var Line $line */
            if ($line->getKey() == $key) {
                $data = $this->decodeData($line->getData());
                break;
            }
        }

        // Save the data to cache
        if ($cache && $data !== false) {
            $cache->set($key, $data);
        }

        return $data;
    }
public function get ( string $ key ) { Validation :: validateKey ( $ key ) ; // Fetch the key from cache if ( $ cache = $ this -> getConfig ( ) -> getCache ( ) ) { if ( $ cache -> contains ( $ key ) ) { return $ cache -> get ( $ key ) ; } } // Fetch the key from database $ file = $ this -> getDatabase ( ) -> readFromFile ( ) ; $ data = false ; foreach ( $ file as $ line ) { /** @var Line $line */ if ( $ line -> getKey ( ) == $ key ) { $ data = $ this -> decodeData ( $ line -> getData ( ) ) ; break ; } } // Save the data to cache if ( $ cache && $ data !== false ) { $ cache -> set ( $ key , $ data ) ; } return $ data ; }
Get a key from the database.

@param string $key

@return mixed
Get a key from the database .