apc_store

(PECL apc >= 3.0.0)

apc_store Cache a variable in the data store

说明

apc_store ( string $key , mixed $var [, int $ttl = 0 ] ) : bool
apc_store ( array $values [, mixed $unused = NULL [, int $ttl = 0 ]] ) : array

缓存一个变量到APC中

Note: 与PHP中其他的机制不同,使用apc_store() 存储的变量 在不同的请求之间一直持久存在(直到从缓存系统中移除)。

参数

key

存储缓存变量使用的名称.key是唯一的,所以 两个值使用同一个 key,原来的将被新的值覆盖。

var

The variable to store

ttl

生存时间;在缓存中存储varttl秒, 在ttl秒过去后,存储的变量将会从缓存中擦除(在下一次请求时), 如果没有设置ttl(或者ttl0), 变量将一直存活到被手动移除为止,除此之外不在缓存中的可能原因是, 缓存系统使用clear,或者restart等。

values

Names in key, variables in value.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE。 Second syntax returns array with error keys.

范例

Example #1 apc_store() 例子

<?php
$bar 
'BAR';
apc_store('foo'$bar);
var_dump(apc_fetch('foo'));
?>

以上例程会输出:

string(3) "BAR"

参见