Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6866 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6866 Rev 6898
Línea 8... Línea 8...
8
 
8
 
9
 
9
 
Línea 10... Línea 10...
10
class CacheImpl implements CacheInterface
10
class CacheImpl implements CacheInterface
Línea 11... Línea 11...
11
{
11
{
12
    
12
    
13
    private $memcached;
13
    private $memcache;
Línea 43... Línea 43...
43
        $this->host   = strval($config['leaderslinked.memcache.host']);
43
        $this->host   = strval($config['leaderslinked.memcache.host']);
44
        $this->port   = intval($config['leaderslinked.memcache.port'], 10);
44
        $this->port   = intval($config['leaderslinked.memcache.port'], 10);
Línea 45... Línea 45...
45
        
45
        
46
        
46
        
47
        if(class_exists(\Memcached::class)) {
47
        if(class_exists(\Memcached::class)) {
48
            $this->memcached = new \Memcached();
48
            $this->memcache = new \Memcached();
49
            $this->memcached->addServer($this->host, $this->port);
49
            $this->memcache->addServer($this->host, $this->port);
50
        } else  if(class_exists(\Memcache::class)) {
50
        } else  if(class_exists(\Memcache::class)) {
51
            $this->memcache = new \Memcache();
51
            $this->memcache = new \Memcache();
Línea 59... Línea 59...
59
     * @param string $key
59
     * @param string $key
60
     * @param mixed $value
60
     * @param mixed $value
61
     */
61
     */
62
    public function setItem($key, $value)
62
    public function setItem($key, $value)
63
    {
63
    {
64
        $this->memcached->add($key, $value, $this->ttl);
64
        return $this->memcache->add($key, $value, $this->ttl);
65
    }
65
    }
Línea 66... Línea 66...
66
    
66
    
67
    /**
67
    /**
68
     * 
68
     * 
69
     * @param string $key
69
     * @param string $key
70
     * @return boolean
70
     * @return boolean
71
     */
71
     */
72
    public function touch($key)
72
    public function touch($key)
73
    {
73
    {
74
        return $this->memcached->touch($key, $this->ttl);
74
        return $this->memcache->touch($key, $this->ttl);
Línea 75... Línea 75...
75
    }
75
    }
76
    
76
    
77
    
77
    
78
    /**
78
    /**
79
     *
79
     *
80
     * @param string $key
80
     * @param string $key
81
     * @return boolean
81
     * @return boolean
82
     */
82
     */
83
    public function removeItem($key)
83
    public function removeItem($key)
Línea 84... Línea 84...
84
    {
84
    {
Línea 92... Línea 92...
92
     * @param string $key
92
     * @param string $key
93
     * @return boolean
93
     * @return boolean
94
     */
94
     */
95
    public function hasItem($key)
95
    public function hasItem($key)
96
    {
96
    {
-
 
97
        
97
        $value = $this->memcached->get($key);
98
        $value = $this->memcache->get($key);
98
        if($value === \Memcached::RES_NOTFOUND) {
99
        if($value === \Memcached::RES_NOTFOUND) {
99
            return false;
100
            return false;
100
        } else {
101
        } else {
101
            return true;
102
            return true;
102
        }
103
        }
Línea 108... Línea 109...
108
     * @param string $key
109
     * @param string $key
109
     * @return mixed
110
     * @return mixed
110
     */
111
     */
111
    public function getItem($key)
112
    public function getItem($key)
112
    {
113
    {
-
 
114
 
-
 
115
        
113
        $value = $this->memcached->get($key);
116
        $value = $this->memcache->get($key);
114
        if($value === \Memcached::RES_NOTFOUND) {
117
        if($value === \Memcached::RES_NOTFOUND) {
115
            return false; 
118
            return false; 
116
        } else {
119
        } else {
117
            return $value;
120
            return $value;
118
        }
121
        }
119
    }
122
    }
-
 
123
    
-
 
124
    
-
 
125
    /**
-
 
126
     *
-
 
127
     * @return bool
-
 
128
     */
-
 
129
    public function available()
-
 
130
    {
-
 
131
        return $this->memcache ? true : false;
-
 
132
    }
Línea 120... Línea 133...
120
 
133