<?php
class ModelExtensionModule301redirect extends Model {
	public function getRedirectByOrigin($url_from){

         $query = $this->db->query("SELECT DISTINCT * FROM ps_301redirect WHERE url_from = '" . $this->db->escape($url_from) . "'");
         return $query->row;

	    //if(isset($this->session->data['user_id'])){

            $redis = new Redis();
            $redis->connect('127.0.0.1', 6379);
            $get_url = $redis->get($url_from);
            if($get_url){
                $get_url = json_decode($get_url, true);
                return $get_url;
            }else{
               // $query = $this->db->query("SELECT DISTINCT * FROM ps_301redirect WHERE url_from = '" . $this->db->escape($url_from) . "'");
                //return $query->row;
            }

            //var_dump($get_url['url_to']); die();

       // }

	    /*
        if($this->cache->cache_get($url_from, 'url_from/'))
            return $this->cache->cache_get($url_from, 'url_from/');


        $query = $this->db->query("SELECT DISTINCT * FROM ps_301redirect WHERE url_from = '" . $this->db->escape($url_from) . "'");
        $this->cache->cache_set($url_from, $query->rows, 'url_from/');
        return $query->row;

        */



	}
}
