10.04.2018 Views

Doctrine_manual-1-2-en

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 23: Caching 322<br />

Chapter 23<br />

Caching<br />

Introduction<br />

<strong>Doctrine</strong>_Cache offers an intuitive and easy-to-use query caching solution. It provides the<br />

following things:<br />

• Multiple cache back<strong>en</strong>ds to choose from (including Memcached, APC and Sqlite)<br />

• Advanced options for fine-tuning. <strong>Doctrine</strong>_Cache has many options for finetuning<br />

performance.<br />

All the cache drivers are instantiated like the following:<br />

Listing<br />

23-1<br />

// bootstrap.php<br />

// ...<br />

$options = array();<br />

$cacheDriver = new <strong>Doctrine</strong>_Cache_Memcache($options);<br />

Each driver has its own possible values for the $options array.<br />

Drivers<br />

Memcache<br />

Memcache driver stores cache records into a memcached server. Memcached is a highperformance,<br />

distributed memory object caching system. In order to use this back<strong>en</strong>d, you<br />

need a memcached daemon and the memcache PECL ext<strong>en</strong>sion.<br />

You can instantiate the Memcache cache driver with the following code:<br />

Listing<br />

23-2<br />

// bootstrap.php<br />

// ...<br />

$servers = array(<br />

'host' => 'localhost',<br />

'port' => 11211,<br />

'persist<strong>en</strong>t' => true<br />

);<br />

----------------- Brought to you by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!