NOTE: For Version 3 of the AWS SDK for PHP, please see the V3 User Guide and V3 API Reference.

# Class DefaultCacheStorage

Default cache storage implementation

  Guzzle\Plugin\Cache\DefaultCacheStorage implements Guzzle\Plugin\Cache\CacheStorageInterface

Namespace: Guzzle\Plugin\Cache
Located at Guzzle/Plugin/Cache/DefaultCacheStorage.php

## Methods summary

- `public` `__construct ( mixed $cache, string $keyPrefix = '', int $defaultTtl = 3600 )`
- `public` `cache ( Guzzle\Http\Message\RequestInterface $request, Guzzle\Http\Message\Response $response )`

  Cache an HTTP request

- `public` `delete ( Guzzle\Http\Message\RequestInterface $request )`

  Deletes cache entries that match a request

- `public` `purge ( string $url )`

  Purge all cache entries for a given URL

- `public` `fetch ( Guzzle\Http\Message\RequestInterface $request )`

  Get a Response from the cache for a request

- `protected` `getCacheKey ( Guzzle\Http\Message\RequestInterface $request )`

  Hash a request URL into a string that returns cache metadata

- `protected` `getBodyKey ( string $url, Guzzle\Http\EntityBodyInterface $body )`

  Create a cache key for a response's body

## Methods detail

# `public`
`__construct( mixed $cache, string $keyPrefix = '', integer $defaultTtl = 3600 )`

#### Parameters

$cache
  `mixed`
  $cache Cache used to store cache data
$keyPrefix
  `string`
  $keyPrefix Provide an optional key prefix to prefix on all cache keys
$defaultTtl
  `integer`
  $defaultTtl Default cache TTL

# `public`
`cache( `Guzzle\Http\Message\RequestInterface` $request, `Guzzle\Http\Message\Response` $response )`

Cache an HTTP request

#### Parameters

$request
  ``Guzzle\Http\Message\RequestInterface``
  $request Request being cached
$response
  ``Guzzle\Http\Message\Response``
  $response Response to cache

#### Implementation of

`Guzzle\Plugin\Cache\CacheStorageInterface::cache()`
# `public`
`delete( `Guzzle\Http\Message\RequestInterface` $request )`

Deletes cache entries that match a request

#### Parameters

$request
  ``Guzzle\Http\Message\RequestInterface``
  $request Request to delete from cache

#### Implementation of

`Guzzle\Plugin\Cache\CacheStorageInterface::delete()`
# `public`
`purge( string $url )`

Purge all cache entries for a given URL

#### Parameters

$url
  `string`
  $url

#### Implementation of

`Guzzle\Plugin\Cache\CacheStorageInterface::purge()`
# `public null|`Guzzle\Http\Message\Response``
`fetch( `Guzzle\Http\Message\RequestInterface` $request )`

Get a Response from the cache for a request

#### Parameters

$request
  ``Guzzle\Http\Message\RequestInterface``
  $request

#### Returns

`null|`Guzzle\Http\Message\Response``

#### Implementation of

`Guzzle\Plugin\Cache\CacheStorageInterface::fetch()`
# `protected string`
`getCacheKey( `Guzzle\Http\Message\RequestInterface` $request )`

Hash a request URL into a string that returns cache metadata

#### Parameters

$request
  ``Guzzle\Http\Message\RequestInterface``
  $request

#### Returns

`string`
# `protected string`
`getBodyKey( string $url, `Guzzle\Http\EntityBodyInterface` $body )`

Create a cache key for a response's body

#### Parameters

$url
  `string`
  $url URL of the entry
$body
  ``Guzzle\Http\EntityBodyInterface``
  $body Response body

#### Returns

`string`

### Magic methods summary

## Properties summary

`protected string` | $keyPrefix | #
`protected `Guzzle\Cache\CacheAdapterInterface`` | $cache | # Cache used to store cache data
`protected integer` | $defaultTtl | # Default cache TTL