public function put($key, $value, $ttl = null)
    {
        $k = $this->hash($key);
        if (isset($this->cache[$k])) {
            $item = $this->cache[$k];
            $item->setValue($value);
            if ($ttl !== null) {
                $item->expire = microtime(true) + $ttl;
            }
            return $item;
        }
        $item = new Item($value);
        if ($ttl !== null) {
            $item->expire = microtime(true) + $ttl;
        }
        $this->cache[$k] = $item;
        $s = sizeof($this->cache);
        if ($s > $this->maxCacheSize + $this->capWindow) {
            uasort($this->cache, $this->sorter);
            for (; $s > $this->maxCacheSize; --$s) {
                array_pop($this->cache);
            }
        }
        return $item;
    }
public function put($key, $value, $ttl = null)
    {
        $k = $this->hash($key);
        if (isset($this->cache[$k])) {
            $item = $this->cache[$k];
            $item->setValue($value);
            if ($ttl !== null) {
                $item->expire = microtime(true) + $ttl;
            }
            return $item;
        }
        $item = new Item($value);
        if ($ttl !== null) {
            $item->expire = microtime(true) + $ttl;
        }
        $this->cache[$k] = $item;
        $s = sizeof($this->cache);
        if ($s > $this->maxCacheSize + $this->capWindow) {
            uasort($this->cache, $this->sorter);
            for (; $s > $this->maxCacheSize; --$s) {
                array_pop($this->cache);
            }
        }
        return $item;
    }
public function put ( $ key , $ value , $ ttl = null ) { $ k = $ this -> hash ( $ key ) ; if ( isset ( $ this -> cache [ $ k ] ) ) { $ item = $ this -> cache [ $ k ] ; $ item -> setValue ( $ value ) ; if ( $ ttl !== null ) { $ item -> expire = microtime ( true ) + $ ttl ; } return $ item ; } $ item = new Item ( $ value ) ; if ( $ ttl !== null ) { $ item -> expire = microtime ( true ) + $ ttl ; } $ this -> cache [ $ k ] = $ item ; $ s = sizeof ( $ this -> cache ) ; if ( $ s > $ this -> maxCacheSize + $ this -> capWindow ) { uasort ( $ this -> cache , $ this -> sorter ) ; for ( ; $ s > $ this -> maxCacheSize ; -- $ s ) { array_pop ( $ this -> cache ) ; } } return $ item ; }
Puts element in cache
@param  string $key Key
@param  mixed $value Value
@param  integer $ttl Time to live
@return mixed
Puts element in cache