array( expires_at|0, value )`. * * @var array */ private $items = array(); /** {@inheritDoc} */ public function get( $key, $fallback = null ) { if ( ! isset( $this->items[ $key ] ) ) { return $fallback; } list( $expires_at, $value ) = $this->items[ $key ]; if ( 0 !== $expires_at && $expires_at < time() ) { unset( $this->items[ $key ] ); return $fallback; } return $value; } /** {@inheritDoc} */ public function set( $key, $value, $ttl = 0 ) { $ttl = (int) $ttl; $this->items[ $key ] = array( $ttl > 0 ? time() + $ttl : 0, $value ); } /** {@inheritDoc} */ public function delete( $key ) { unset( $this->items[ $key ] ); } }