Scrapbook

SimpleCache
in package
implements CacheInterface, CounterInterface

Tags
author

Matthias Mullie [email protected]

copyright

Copyright (c) 2014, Matthias Mullie. All rights reserved.

license

LICENSE MIT

Table of Contents

Interfaces

CacheInterface
CounterInterface

Methods

__construct()  : mixed
clear()  : void
Wipe clean the entire cache's keys
decrement()  : int|bool
Decrement a value atomically in the cache by its step value, which defaults to 1
delete()  : void
Delete an item from the cache by its unique key
deleteMultiple()  : void
Delete multiple cache items in a single operation
exists()  : bool
Identify if an item is in the cache.
get()  : mixed
Fetch a value from the cache.
getMultiple()  : array<string|int, mixed>
Obtain multiple cache items by their unique keys
increment()  : int|bool
Increment a value atomically in the cache by its step value, which defaults to 1
set()  : bool
Persist data in the cache, uniquely referenced by a key with an optional expiration TTL time.
setMultiple()  : bool
Persisting a set of key => value pairs in the cache, with an optional TTL.

Methods

clear()

Wipe clean the entire cache's keys

public clear() : void

decrement()

Decrement a value atomically in the cache by its step value, which defaults to 1

public decrement(mixed $key[, mixed $step = 1 ]) : int|bool
Parameters
$key : mixed

The cache item key

$step : mixed = 1

The value to decrement by, defaulting to 1

Return values
int|bool

The new value on success and false on failure

delete()

Delete an item from the cache by its unique key

public delete(mixed $key) : void
Parameters
$key : mixed

The unique cache key of the item to delete

deleteMultiple()

Delete multiple cache items in a single operation

public deleteMultiple(mixed $keys) : void
Parameters
$keys : mixed

The array of string-based keys to be deleted

exists()

Identify if an item is in the cache.

public exists(mixed $key) : bool
Parameters
$key : mixed

The cache item key

Return values
bool

get()

Fetch a value from the cache.

public get(mixed $key) : mixed
Parameters
$key : mixed

The unique key of this item in the cache

Return values
mixed

The value of the item from the cache, or null in case of cache miss

getMultiple()

Obtain multiple cache items by their unique keys

public getMultiple(mixed $keys) : array<string|int, mixed>
Parameters
$keys : mixed

A list of keys that can obtained in a single operation.

Return values
array<string|int, mixed>

An array of key => value pairs. Cache keys that do not exist or are stale will have a value of null.

increment()

Increment a value atomically in the cache by its step value, which defaults to 1

public increment(mixed $key[, mixed $step = 1 ]) : int|bool
Parameters
$key : mixed

The cache item key

$step : mixed = 1

The value to increment by, defaulting to 1

Return values
int|bool

The new value on success and false on failure

set()

Persist data in the cache, uniquely referenced by a key with an optional expiration TTL time.

public set(mixed $key, mixed $value[, mixed $ttl = null ]) : bool
Parameters
$key : mixed

The key of the item to store

$value : mixed

The value of the item to store

$ttl : mixed = null

Optional. The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that.

Return values
bool

True on success and false on failure

setMultiple()

Persisting a set of key => value pairs in the cache, with an optional TTL.

public setMultiple(mixed $items[, mixed $ttl = null ]) : bool
Parameters
$items : mixed

An array of key => value pairs for a multiple-set operation.

$ttl : mixed = null

Optional. The amount of seconds from the current time that the item will exist in the cache for. If this is null then the cache backend will fall back to its own default behaviour.

Return values
bool

True on success and false on failure


        
On this page

Search results