<?php
/*-------------------------------------
	版权所有：南京牛昆网络科技有限公司（TEL-15896098989）
	程序版本：1.0
	更新日期：2015-05-26  
-------------------------------------*/

class urlcache
{
	private $db;
	private $cachetable;

    function __construct()
    {
		global $db;
		$this->db = $db;
		$this->cachetable = LA_PRE.'url';
    }

    function urlcache()
    {
		$this->__construct();
    }

	function get($key)
    {
       $r=$this->db->fetch_one("SELECT * FROM `$this->cachetable` WHERE `$this->cachetable`.`key`='".la_md5(strtolower($key))."'");
	   return $r?$r['url']:'';
    }

    function set($key,$url)
    {
		return $this->db->insert($this->cachetable,array('key'=>la_md5(strtolower($key)),'url'=>trim($url)),true);
    }

    function rm($key)
    {
		return $this->db->query("DELETE FROM `$this->cachetable` WHERE `key`='".la_md5(strtolower($key))."'",true);
    }

    function clear()
    {
		return $this->db->query("TRUNCATE TABLE `$this->cachetable`",true);
    }
}
?>
