\apex\app\iocache

Cache Handler

Service: apex\svc\cache

Handles all cache items and related functionality, including set, get, and expire cache items.

This class is available within the services container, meaning its methods can be accessed statically via the service singleton as shown below.

PHP Example

<?php

namespace apex;

use apex\app; use apex\svc\cache;

( ( // Set cache item cache::set('some_id', 'my item contents');

// Get cache item $data = cache::get('some_id');

Summary

Methods
Properties
Constants
get()
has()
set()
delete()
clear()
mset()
mdelete()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

get()

get(string  $key, mixed  $default_value = false) : mixed

Get cache item.

Parameters

string $key

The key of the cache item.

mixed $default_value

Optional default value to return, if no cache exists. Defaults to false.

Returns

mixed —

Value of the cache item, or default value if not exists.

has()

has(string  $key) : boolean

CHeck if cache item exists

Parameters

string $key

Key of chache item to check

Returns

boolean —

Whether or not cache item exists

set()

set(string  $key, mixed  $value, integer  $ttl = 300) 

Set cache item

Parameters

string $key

Key of the cache item

mixed $value

The value of the item.

integer $ttl

The TTL of the cache item.

delete()

delete(string  $key) 

Delete cache item

Parameters

string $key

Item to delte

clear()

clear() 

Clear the cache.

mset()

mset(array  $items, integer  $ttl) : array

Get multiple cache items.

Parameters

array $items

The items to key.

integer $ttl

The TTL in secions of all items.

Returns

array —

The values of all found keys.

public function gets(...$keys) {

// GO through keys $values = array(); foreach ($keys as $key) { $values[$key] = $this->get($key); }

// Return return $values;

}

Set multiple cache items.

mdelete()

mdelete(\apex\app\io\iterable  $keys) 

Delete multiple cache items.

Parameters

\apex\app\io\iterable $keys

The item keys to delete.