Zend Data Cache - PHP API

This topic lists the PHP API functions of the Zend Data Cache.

Zend Data Cache Functions

Function

Description

zend_shm_cache_store

Stores a variable identified by key into the cache. If a namespace is provided, the key is stored under that namespace. Identical keys can exist under different namespaces.

zend_shm_cache_add

Stores a variable identified by key into the memory cache. If the given key is already cached, it won't be modified. If a namespace is provided, the key is stored under that namespace. Identical keys can exist under different namespaces.

zend_disk_cache_store

Stores a variable identified by a key into the cache. If a namespace is provided, the key is stored under that namespace. Identical keys can exist under different namespaces.

zend_diskcache_add

Stores a variable identified by key into the disk cache. If the given key is already cached, it won't be modified. If a namespace is provided, the key is stored under that namespace. Identical keys can exist under different namespaces.

zend_shm_cache_fetch

Fetches data from the cache. The key can be prefixed with a namespace to indicate searching within the specified namespace only. If a namespace is not provided, the Data Cache searches for the key in the global namespace.

zend_shm_cache_info

Provide the user information about the memory data cache

zend_disk_cache_fetch

Fetches data from the cache. The key can be prefixed with a namespace to indicate searching within the specified namespace only. If a namespace is not provided, the Data Cache searches for the key in the global namespace.

zend_shm_cache_delete

Finds and deletes an entry from the cache, using a key to identify it. The key can be prefixed with a namespace to indicate that the key can be deleted within that namespace only. If a namespace is not provided, the Data Cache searches for the key in the global namespace.

zend_disk_cache_delete

Finds and deletes an entry from the cache, using a key to identify it. The key can be prefixed with a namespace to indicate that the key can be deleted within that namespace only. If a namespace is not provided, the Data Cache searches for the key in the global namespace.

zend_shm_cache_clear

Deletes all entries from all namespaces in the cache, if a 'namespace' is provided, only the entries in that namespace are deleted.

zend_disk_cache_clear

Deletes all entries from all namespaces in the cache, if a 'namespace' is provided, only the entries in that namespace are deleted.

zend_shm_cache_exist

Check existence of shared memory cache entry by key

zend_disk_cache_exist

Check existence of disk cache entry by key

zend_shm_cache_store

Stores a variable identified by key into the cache. If a namespace is provided, the key is stored under that namespace. Identical keys can exist under different namespaces.

Available Since Version: 4.0

Parameter

Type

Required

Description

key

string

Yes

The data's key. Optional: prefix with a [namespace::].

value

mixed

Yes

Any PHP object that can be serialized.

ttl

int

No

Time to live, in seconds. The Data Cache keeps an object in the cache as long as the TTL is not expired. Once the TTL is expired, the object is removed from the cache.

Return Value: boolean - FALSE if cache storing fails, TRUE otherwise.

zend_shm_cache_add

Stores a variable identified by key into the memory cache. If the given key is already cached, it won't be modified. If a namespace is provided, the key is stored under that namespace. Identical keys can exist under different namespaces.

Available Since Version: 8.0

Parameter

Type

Required

Description

key

string

Yes

The data's key. Optional: prefix with a [namespace::].

value

mixed

Yes

Any PHP object that can be serialized.

ttl

int

No

Time to live, in seconds. The Data Cache keeps an object in the cache as long as the TTL is not expired. Once the TTL is expired, the object is removed from the cache.

Return Value: boolean - TRUE if cache storing done successfully, FALSE otherwise. If the given key is already cached, return FALSE.

zend_disk_cache_store

Stores a variable identified by a key into the cache. If a namespace is provided, the key is stored under that namespace. Identical keys can exist under different namespaces.

Available Since Version: 4.0

Parameter

Type

Required

Description

key

string

Yes

The data key. Optional: prefix with a namespace.

value

mixed

Yes

Any PHP object that can be serialized.

ttl

int

No

Time to live, in seconds. The Data Cache keeps objects in the cache as long as the TTL is not expired. Once the TTL is expired, the object is removed from the cache.

Return Value: boolean - FALSE if cache storing fails, TRUE otherwise.

zend_diskcache_add

Stores a variable identified by key into the disk cache. If the given key is already cached, it won't be modified. If a namespace is provided, the key is stored under that namespace. Identical keys can exist under different namespaces.

Available Since Version: 8.0

Parameter

Type

Required

Description

key

string

Yes

The data's key. Optional: prefix with a [namespace::].

value

mixed

Yes

Any PHP object that can be serialized.

ttl

int

No

Time to live, in seconds. The Data Cache keeps an object in the cache as long as the TTL is not expired. Once the TTL is expired, the object is removed from the cache.

Return Value: boolean - TRUE if cache storing done successfully, FALSE otherwise. If the given key is already cached, return FALSE.

zend_shm_cache_fetch

Fetches data from the cache. The key can be prefixed with a namespace to indicate searching within the specified namespace only. If a namespace is not provided, the Data Cache searches for the key in the global namespace.

Available Since Version: 4.0

Parameter

Type

Required

Description

key

mixed

Yes

The data key or an array of data keys. Optional for key's name: prefix with a namespace.

Return Value: mixed - FALSE if no data that matches the key is found, else it returns the stored data. If an array of keys is given, then an array, which its keys are the original keys and the values, are the corresponding stored data values.

zend_shm_cache_info

Provide the user information about the memory data cache

Available Since Version: 8.0

Return Value: mixed - FALSE if the Zend Data Cache is disabled else array , which contains information about the allocated and used memory per namespace.

zend_disk_cache_fetch

Fetches data from the cache. The key can be prefixed with a namespace to indicate searching within the specified namespace only. If a namespace is not provided, the Data Cache searches for the key in the global namespace.

Available Since Version: 4.0

Parameter

Type

Required

Description

key

mixed

Yes

The data key or an array of data keys. Optional for key's name: prefix with a namespace.

Return Value: mixed - FALSE if no data that matches the key is found, else it returns the stored data. If an array of keys is given, then an array, which its keys are the original keys and the values, are the corresponding stored data values

zend_shm_cache_delete

Finds and deletes an entry from the cache, using a key to identify it. The key can be prefixed with a namespace to indicate that the key can be deleted within that namespace only. If a namespace is not provided, the Data Cache searches for the key in the global namespace.

Available Since Version: 4.0

Parameter

Type

Required

Description

key

mixed

Yes

The data key or an array of data keys. Optional for key's name: prefix with a namespace.

clusterDelete

boolean

No

When set to true (the default), the entry is deleted across the cluster

Return Value: boolean - TRUE on success, FALSE on failure.

zend_disk_cache_delete

Finds and deletes an entry from the cache, using a key to identify it. The key can be prefixed with a namespace to indicate that the key can be deleted within that namespace only. If a namespace is not provided, the Data Cache searches for the key in the global namespace.

Available Since Version: 4.0

Parameter

Type

Required

Description

key

string

Yes

The data key or an array of data keys. Optional for key's name: prefix with a namespace.

clusterDelete

boolean

No

When set to true (the default), the entry is deleted across the cluster

Return Value: boolean - TRUE on success, FALSE on failure or when entry doesn't exist.

zend_shm_cache_clear

Deletes all entries from all namespaces in the cache, if a 'namespace' is provided, only the entries in that namespace are deleted.

Available Since Version: 4.0

Parameter

Type

Required

Description

namespace

string

Yes

The data key. Optional: prefix with a namespace.

clusterDelete

boolean

No

When set to true (the default) the clear is taking place across the cluster

Return Value: boolean - If the namespace does not exist or there are no items to clear, the function will return TRUE. The function will return FALSE only in case of error.

zend_disk_cache_clear

Deletes all entries from all namespaces in the cache, if a 'namespace' is provided, only the entries in that namespace are deleted.

Available Since Version: 4.0

Parameter

Type

Required

Description

namespace

string

Yes

The data key. Optional: prefix with a namespace.

clusterDelete

boolean

No

When set to true (the default) the clear is taking place across the cluster

Return Value: boolean - If the namespace does not exist, or there are no items to clear, the function will return TRUE. The function will return FALSE only in case of error.

zend_shm_cache_exist

Check existence of shared memory cache entry by key

Available Since Version: 6.3

Parameter

Type

Required

Description

key

string

Yes

The data key

Return Value: boolean - True is exists. False otherwise.

zend_disk_cache_exist

Check existence of disk cache entry by key

Available Since Version: 6.3

Parameter

Type

Required

Description

key

string

Yes

The data key

Return Value: boolean - True is exists. False otherwise.