PHP 클래스 MatthiasMullie\Scrapbook\Adapters\SQL

This abstract class should be a "fits all DB engines" normalization. It's up to extending classes to optimize for that specific engine.
저자: Matthias Mullie ([email protected])
상속: implements MatthiasMullie\Scrapbook\KeyValueStore
파일 보기 프로젝트 열기: matthiasmullie/scrapbook

보호된 프로퍼티들

프로퍼티 타입 설명
$client PDO
$table string

공개 메소드들

메소드 설명
__construct ( PDO $client, string $table = 'cache' )
add ( $key, $value, $expire )
cas ( $token, $key, $value, $expire )
decrement ( $key, $offset = 1, $initial, $expire )
delete ( $key )
deleteMulti ( array $keys )
flush ( )
get ( $key, &$token = null )
getMulti ( array $keys, array &$tokens = null )
increment ( $key, $offset = 1, $initial, $expire )
replace ( $key, $value, $expire )
set ( $key, $value, $expire )
setMulti ( array $items, $expire )
touch ( $key, $expire )

보호된 메소드들

메소드 설명
clearExpired ( ) Expired entries shouldn't keep filling up the database. Additionally, we will want to remove those in order to properly rely on INSERT (for add) and UPDATE (for replace), which assume a column exists or not, not taking the expiration status into consideration.
doIncrement ( string $key, integer $offset, integer $initial, integer $expire ) : integer | boolean Shared between increment/decrement: both have mostly the same logic (decrement just increments a negative value), but need their validation & use of non-ttl native methods split up.
expire ( integer $expire ) : null | string Transforms expiration times into TIMESTAMP (Y-m-d H:i:s) format, which DB will understand and be able to compare with other dates.
init ( ) Create the database/indices if it does not already exist.
serialize ( mixed $value ) : string | integer I originally didn't want to serialize numeric values because I planned on incrementing them in the DB, but revisited that idea.
unserialize ( mixed $value ) : mixed | integer | float Numbers aren't serialized for storage size purposes.

메소드 상세

__construct() 공개 메소드

public __construct ( PDO $client, string $table = 'cache' )
$client PDO
$table string

add() 공개 메소드

public add ( $key, $value, $expire )

cas() 공개 메소드

public cas ( $token, $key, $value, $expire )

clearExpired() 보호된 메소드

An expired column should simply not exist.
protected clearExpired ( )

decrement() 공개 메소드

public decrement ( $key, $offset = 1, $initial, $expire )

delete() 공개 메소드

public delete ( $key )

deleteMulti() 공개 메소드

public deleteMulti ( array $keys )
$keys array

doIncrement() 보호된 메소드

Shared between increment/decrement: both have mostly the same logic (decrement just increments a negative value), but need their validation & use of non-ttl native methods split up.
protected doIncrement ( string $key, integer $offset, integer $initial, integer $expire ) : integer | boolean
$key string
$offset integer
$initial integer
$expire integer
리턴 integer | boolean

expire() 보호된 메소드

Transforms expiration times into TIMESTAMP (Y-m-d H:i:s) format, which DB will understand and be able to compare with other dates.
protected expire ( integer $expire ) : null | string
$expire integer
리턴 null | string

flush() 공개 메소드

public flush ( )

get() 공개 메소드

public get ( $key, &$token = null )

getMulti() 공개 메소드

public getMulti ( array $keys, array &$tokens = null )
$keys array
$tokens array

increment() 공개 메소드

public increment ( $key, $offset = 1, $initial, $expire )

init() 추상적인 보호된 메소드

Create the database/indices if it does not already exist.
abstract protected init ( )

replace() 공개 메소드

public replace ( $key, $value, $expire )

serialize() 보호된 메소드

However, not serializing numbers still causes some small DB storage gains and it's safe (serialized data can never be confused for an int).
protected serialize ( mixed $value ) : string | integer
$value mixed
리턴 string | integer

set() 공개 메소드

public set ( $key, $value, $expire )

setMulti() 공개 메소드

public setMulti ( array $items, $expire )
$items array

touch() 공개 메소드

public touch ( $key, $expire )

unserialize() 보호된 메소드

Numbers aren't serialized for storage size purposes.
protected unserialize ( mixed $value ) : mixed | integer | float
$value mixed
리턴 mixed | integer | float

프로퍼티 상세

$client 보호되어 있는 프로퍼티

protected PDO $client
리턴 PDO

$table 보호되어 있는 프로퍼티

protected string $table
리턴 string