Copy CodeThe code is as follows:
<?php
/**
* Adapter Mode
*
* Convert the interface of a class to another interface that the customer expects, and those classes that are not compatible to work together can work together
*/
This is the original type.
Class Oldcache
{
Public Function __construct ()
{
echo "Oldcache construct<br/>";
}
Public function Store ($key, $value)
{
echo "Oldcache store<br/>";
}
Public function Remove ($key)
{
echo "Oldcache remove<br/>";
}
Public function Fetch ($KEY)
{
echo "Oldcache fetch<br/>";
}
}
Interface cacheable
{
Public function set ($key, $value);
Public function get ($key);
Public Function del ($key);
}
Class Oldcacheadapter implements Cacheable
{
Private $_cache = null;
Public Function __construct ()
{
$this->_cache = new Oldcache ();
}
Public function set ($key, $value)
{
return $this->_cache->store ($key, $value);
}
Public function Get ($key)
{
return $this->_cache->fetch ($key);
}
Public Function del ($key)
{
return $this->_cache->remove ($key);
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.