lib/RedisLite.php
public function keys($pattern = null) {

        $keys = array();
        $stmt = $this->connection->query("SELECT `key` FROM ".$this->table." ORDER BY `key`;");
        $res  = $stmt->fetchAll(\PDO::FETCH_ASSOC);

        if (!$pattern) {

            foreach ($res as $record) {
                $keys[] = $record["key"];
            }

        } else {

            $matcher = function_exists('fnmatch') ? 'fnmatch': function($pattern, $string){
                return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
            };

            foreach ($res as $record) {
                if($matcher($pattern, $record["key"])) {
                    $keys[] = $record["key"];
                }
            }
        }

        return $keys;
    }
public function keys($pattern = null) {

        $keys = array();
        $stmt = $this->connection->query("SELECT `key` FROM ".$this->table." ORDER BY `key`;");
        $res  = $stmt->fetchAll(\PDO::FETCH_ASSOC);

        if (!$pattern) {

            foreach ($res as $record) {
                $keys[] = $record["key"];
            }

        } else {

            $matcher = function_exists('fnmatch') ? 'fnmatch': function($pattern, $string){
                return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
            };

            foreach ($res as $record) {
                if($matcher($pattern, $record["key"])) {
                    $keys[] = $record["key"];
                }
            }
        }

        return $keys;
    }
public function keys ( $ pattern = null ) { $ keys = array ( ) ; $ stmt = $ this -> connection -> query ( "SELECT `key` FROM " . $ this -> table . " ORDER BY `key`;" ) ; $ res = $ stmt -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; if ( ! $ pattern ) { foreach ( $ res as $ record ) { $ keys [ ] = $ record [ "key" ] ; } } else { $ matcher = function_exists ( 'fnmatch' ) ? 'fnmatch' : function ( $ pattern , $ string ) { return preg_match ( "#^" . strtr ( preg_quote ( $ pattern , '#' ) , array ( '\*' => '.*' , '\?' => '.' ) ) . "$#i" , $ string ) ; } ; foreach ( $ res as $ record ) { if ( $ matcher ( $ pattern , $ record [ "key" ] ) ) { $ keys [ ] = $ record [ "key" ] ; } } } return $ keys ; }
Get all keys matching a pattern

@param  string $pattern
@return array
Get all keys matching a pattern