• PHP reference

Cache

class Cache extends ExtendableObject

A simple interface to the Scholica cache layer, based on Redis.

Methods

mixed get(string $key)

Get variable from cache.

Parameters

  • string $key

Return Value

  • mixed

boolean set(string $key, mixed $value, integer $ttl = 259200, array|string $tags = null)

Save variable in cache.

Parameters

  • string $key Cache key
  • mixed $value Value to sve
  • integer $ttl Time to live (store) in seconds
  • array|string $tags Array of tags for this key

Return Value

  • boolean

boolean|array del(string|array $keys)

Delete one or more keys from storage.

Parameters

  • string|array $keys Cache key(s)

Return Value

  • boolean|array if array of keys was passed, on error will be returned array of not deleted keys, or 'true' on success

boolean|array delete(string|array $keys)

Delete one or more keys from storage (shim for del()).

Parameters

  • string|array $keys Cache key(s)

Return Value

  • boolean|array if array of keys was passed, on error will be returned array of not deleted keys, or 'true' on success

boolean del_by_tags(array|string $tags)

Delete keys by tags.

Parameters

  • array|string $tags Tag or array of tags

Return Value

  • boolean

boolean exists(string $key)

Check if key exists.

Parameters

  • string $key Cache key

Return Value

  • boolean

boolean sets_set(string $key, array $fields)

Set the contents of a set.

Parameters

  • string $key Set key
  • array $fields Set fields

Return Value

  • boolean

array|null sets_get(String $key)

Get the values in a set (HVALS).

Parameters

  • String $key Set key

Return Value

  • array|null

boolean sets_set_key(string $key, string $field, mixed $value)

Set the value for a specific key in a set (HSET).

Parameters

  • string $key Set key
  • string $field Field key
  • mixed $value Field value

Return Value

  • boolean

mixed sets_get_key(string $key, string $field)

Get the value of a single key in a set (HGET).

Parameters

  • string $key Set key
  • string $field Field key

Return Value

  • mixed

boolean sets_del_key(string $key, string $field)

Delete a single key in a set (HDEL).

Parameters

  • string $key Set key
  • string $field Field key

Return Value

  • boolean

array|null sets_all($key)

Get all fields and values in a set.

Parameters

  • $key

Return Value

  • array|null

Inherited from ExtendableObject

__construct()

Constructor.

final static ExtendableObject instance()

Get instance.

Return Value

final static boolean hasInstance()

Check whether there is an instance of this class available.

Return Value

  • boolean

final boolean extension($extension)

Call class method, if it exists.

Parameters

  • $extension

Return Value

  • boolean