PEAR_REST::saveCache

PEAR_REST::saveCache()

PEAR_REST::saveCache()  -- Save the value retrieved from a remote REST resource in the local cache.

Description

Use this to save a resource after retrieving. Since the cache_ttl configuration variable is used in determining when to check the remote server, and HTTP caching is used as well, it is possible for this scenario to arise:

  1. retrieve REST resource

  2. cache the resource

  3. a few days later, retrieve the REST resource again

  4. HTTP caching returns 304 not modified

In this situation, it doesn't make much sense to save the resource contents redundantly. Instead, the last access time can be saved in the cache id by passing true into the last parameter.

Parameter

string $url

The REST resource's URL

mixed $contents

Contents retrieved from the REST resource (ignored if the last parameter is true)

array $lastmodified

The ETag and LastModified headers retrieved from the remote server, used for HTTP caching.

mixed $nochange

If false, the cache is saved normally. If true, only the $lastmodified parameter is saved in the cache id file, registering an HTTP cache hit.

Throws

throws no exceptions thrown

Note

This function can not be called statically.

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.