public function indexAction()
    {
        $results = array();
        $key  = '';
        $db   = '-1';
        if($this->getRequest()->isMethod('POST')) {
            $key = $this->getRequest()->get('key');
            $db  = $this->getRequest()->get('database');

            $keys = $this->getWorker()->keys($key, $db);

            if(empty($keys)) {
                $this->get('session')->getFlashBag()->add('notice', 'No result found');
            }else if(is_array($keys)) {
                foreach($keys as $k) {
                    $value = $this->getWorker()->get($k, $db);
                    $ttl = $this->getWorker()->ttl($k, $db);
                    $results[] = array(
                        'key'      => $k,
                        'value'    => $value,
                        'expireAt' => ($ttl == -1) ? '-' : strftime("%a %d %b %H:%M:%S %Y", time() + $ttl),
                        'weight'   => (mb_strlen($value, '8bit') / 1000). ' Kb'
                    );
                }
            }
        }

        return $this->render(
            $this->getTemplatePath().'index.html.twig',
            array(
                'instance'  => $this->getCurrentInstance(),
                'results'   => $results,
                'key'       => $key,
                'db'        => $db
            )
        );
    }
public function indexAction()
    {
        $results = array();
        $key  = '';
        $db   = '-1';
        if($this->getRequest()->isMethod('POST')) {
            $key = $this->getRequest()->get('key');
            $db  = $this->getRequest()->get('database');

            $keys = $this->getWorker()->keys($key, $db);

            if(empty($keys)) {
                $this->get('session')->getFlashBag()->add('notice', 'No result found');
            }else if(is_array($keys)) {
                foreach($keys as $k) {
                    $value = $this->getWorker()->get($k, $db);
                    $ttl = $this->getWorker()->ttl($k, $db);
                    $results[] = array(
                        'key'      => $k,
                        'value'    => $value,
                        'expireAt' => ($ttl == -1) ? '-' : strftime("%a %d %b %H:%M:%S %Y", time() + $ttl),
                        'weight'   => (mb_strlen($value, '8bit') / 1000). ' Kb'
                    );
                }
            }
        }

        return $this->render(
            $this->getTemplatePath().'index.html.twig',
            array(
                'instance'  => $this->getCurrentInstance(),
                'results'   => $results,
                'key'       => $key,
                'db'        => $db
            )
        );
    }
public function indexAction ( ) { $ results = array ( ) ; $ key = '' ; $ db = '-1' ; if ( $ this -> getRequest ( ) -> isMethod ( 'POST' ) ) { $ key = $ this -> getRequest ( ) -> get ( 'key' ) ; $ db = $ this -> getRequest ( ) -> get ( 'database' ) ; $ keys = $ this -> getWorker ( ) -> keys ( $ key , $ db ) ; if ( empty ( $ keys ) ) { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'notice' , 'No result found' ) ; } else if ( is_array ( $ keys ) ) { foreach ( $ keys as $ k ) { $ value = $ this -> getWorker ( ) -> get ( $ k , $ db ) ; $ ttl = $ this -> getWorker ( ) -> ttl ( $ k , $ db ) ; $ results [ ] = array ( 'key' => $ k , 'value' => $ value , 'expireAt' => ( $ ttl == - 1 ) ? '-' : strftime ( "%a %d %b %H:%M:%S %Y" , time ( ) + $ ttl ) , 'weight' => ( mb_strlen ( $ value , '8bit' ) / 1000 ) . ' Kb' ) ; } } } return $ this -> render ( $ this -> getTemplatePath ( ) . 'index.html.twig' , array ( 'instance' => $ this -> getCurrentInstance ( ) , 'results' => $ results , 'key' => $ key , 'db' => $ db ) ) ; }
Search index action

@return \Symfony\Component\HttpFoundation\Response
Search index action