Db
extends AbstractAdapter
in package
Database cache adapter class
Tags
Table of Contents
- $db : AbstractAdapter
- Database adapter
- $table : string
- Cache db table
- $ttl : int
- Global time-to-live
- __construct() : mixed
- Constructor
- clear() : Db
- Clear all stored values from cache
- deleteItem() : Db
- Delete a value in cache
- destroy() : Db
- Destroy cache resource
- getDb() : AbstractAdapter
- Get the current cache db adapter.
- getItem() : mixed
- Get an item from cache
- getItemTtl() : int
- Get the time-to-live for an item in cache
- getTable() : string
- Get the current cache db table.
- getTtl() : int
- Get the global time-to-live for the cache object
- hasItem() : bool
- Determine if the item exist in cache
- saveItem() : Db
- Save an item to cache
- setDb() : Db
- Set the current cache db adapter.
- setTable() : Db
- Set the cache db table
- setTtl() : AbstractAdapter
- Set the global time-to-live for the cache adapter
- createTable() : void
- Create table in database
Properties
$db
Database adapter
protected
AbstractAdapter
$db
= null
$table
Cache db table
protected
string
$table
= 'pop_cache'
$ttl
Global time-to-live
protected
int
$ttl
= 0
Methods
__construct()
Constructor
public
__construct(AbstractAdapter $db, int $ttl[, string $table = 'pop_cache' ]) : mixed
Instantiate the DB writer object
The DB table requires the following fields at a minimum:
id INT
key VARCHAR
start INT
ttl INT
value TEXT, VARCHAR, etc.
Parameters
- $db : AbstractAdapter
- $ttl : int
- $table : string = 'pop_cache'
Return values
mixed —clear()
Clear all stored values from cache
public
clear() : Db
Return values
Db —deleteItem()
Delete a value in cache
public
deleteItem(string $id) : Db
Parameters
- $id : string
Return values
Db —destroy()
Destroy cache resource
public
destroy() : Db
Return values
Db —getDb()
Get the current cache db adapter.
public
getDb() : AbstractAdapter
Return values
AbstractAdapter —getItem()
Get an item from cache
public
getItem(string $id) : mixed
Parameters
- $id : string
Return values
mixed —getItemTtl()
Get the time-to-live for an item in cache
public
getItemTtl(string $id) : int
Parameters
- $id : string
Return values
int —getTable()
Get the current cache db table.
public
getTable() : string
Return values
string —getTtl()
Get the global time-to-live for the cache object
public
getTtl() : int
Return values
int —hasItem()
Determine if the item exist in cache
public
hasItem(string $id) : bool
Parameters
- $id : string
Return values
bool —saveItem()
Save an item to cache
public
saveItem(string $id, mixed $value[, int $ttl = null ]) : Db
Parameters
- $id : string
- $value : mixed
- $ttl : int = null
Return values
Db —setDb()
Set the current cache db adapter.
public
setDb(string $db) : Db
Parameters
- $db : string
Return values
Db —setTable()
Set the cache db table
public
setTable(string $table) : Db
Parameters
- $table : string
Return values
Db —setTtl()
Set the global time-to-live for the cache adapter
public
setTtl(int $ttl) : AbstractAdapter
Parameters
- $ttl : int
Return values
AbstractAdapter —createTable()
Create table in database
protected
createTable() : void