DBEnumBase

DBEnumBase 枚举类型

对数量不确定的内容,利用 MySQL 自增 id 编号,并通过 MRU(最近最频繁使用)算法缓存于 PHP 变量内存中 典型场合如域名、文件名等

abstract
package
author

Zheng Kai zhengkai@gmail.com

Methods

如变量缓存池满,踢掉用到的最少的那

_checkPoolFull() : boolean
static
static
access

protected

Response

boolean

预读,如果变量缓存池是空的,第一次从数据库取的时候, 一次性取 _iPoolMax 条(默认1000),以减少 mysql 请求数

_checkPreload() : void
static
static
access

protected

获取数据库连接

_getDB() : \Tango\Drive\DB
static
static
access

protected

throws

Response

\Tango\Drive\DB

按照 static::$_sKeyHash 指定的方式做 hash

_hash(mixed $aSearch) : void
static
static
access

protected

Arguments

$aSearch

mixed

实际预读操作

_preload() : void
static
static
access

protected

实际预读操作(带 hash)

_preloadWithHash() : void
static
static
access

protected

给内容分配 id

get(mixed $aSearch) : void
access

public

Arguments

$aSearch

mixed

根据 id 获取指定内容

getById(mixed $iID) : mixed
access

public

throws

Arguments

$iID

mixed

Response

mixed

Properties

数据库连接名(是给 \Tango\Drive\DB 用的库名alias,不是实际的 MySQL db 名)

_sDB : 
static
see

Type(s)

数据库表名

_sDBTable : 
static

Type(s)

id 的字段名

_sKeyID : 
static

Type(s)

内容的字段名

_lKeySearch : 
static

Type(s)

如果需要 hash,定义 hash 的字段名

_sKeyHash : 
static

注意有些内容是定长的(可以用 int 或者 char 装下的,如用户名),而有些内容是过长(如 char(200) 才能装下、或者合法 URL 可以到 4KB),建议做 hash

Type(s)

hash 方式

_sHashAlgo : 
static
see

Type(s)

只记内容 id 的变量缓存池

_lPool : 
static

Type(s)

变量缓存池

_lPoolForName : 
static

Type(s)

MRU 计数器

_lPoolForSort : 
static

Type(s)

变量缓存池数量

_iPoolMax : 
static

Type(s)

预读,第一次加载的时候是否 SELECT LIMIT 1000

_bPreLoad : 
static

Type(s)

变量缓存池数量(节省点 count(self::$_lPool) 的效率)

_iPoolNum : 
static

Type(s)

变量缓存池是否已满

_bPoolFull : 
static

Type(s)

查询次数

_iGet : 
static

Type(s)

访问数据库次数

_iDB : 
static

Type(s)