本文整理汇总了PHP中get_offset_sec函数的典型用法代码示例。如果您正苦于以下问题:PHP get_offset_sec函数的具体用法?PHP get_offset_sec怎么用?PHP get_offset_sec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_offset_sec函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Object constructor.
*
* @param string $type Engine type ('db' or 'memcache' or 'apc')
* @param int $userid User identifier
* @param string $prefix Key name prefix
* @param string $ttl Expiration time of memcache/apc items
* @param bool $packed Enables/disabled data serialization.
* It's possible to disable data serialization if you're sure
* stored data will be always a safe string
*/
function __construct($type, $userid, $prefix = '', $ttl = 0, $packed = true)
{
$rcube = rcube::get_instance();
$type = strtolower($type);
if ($type == 'memcache') {
$this->type = 'memcache';
$this->db = $rcube->get_memcache();
} else {
if ($type == 'apc') {
$this->type = 'apc';
$this->db = function_exists('apc_exists');
// APC 3.1.4 required
} else {
$this->type = 'db';
$this->db = $rcube->get_dbh();
$this->table = $this->db->table_name('cache');
}
}
// convert ttl string to seconds
$ttl = get_offset_sec($ttl);
if ($ttl > 2592000) {
$ttl = 2592000;
}
$this->userid = (int) $userid;
$this->ttl = $ttl;
$this->packed = $packed;
$this->prefix = $prefix;
}
开发者ID:bbspike,项目名称:sentora-core,代码行数:39,代码来源:rcube_cache.php
示例2: test_get_offset_sec
/**
* rcube_shared.inc: get_offset_sec()
*/
function test_get_offset_sec()
{
$data = array('1s' => 1, '1m' => 1 * 60, '1h' => 1 * 60 * 60, '1d' => 1 * 60 * 60 * 24, '1w' => 1 * 60 * 60 * 24 * 7, '1y' => (int) '1y', 100 => 100, '100' => 100);
foreach ($data as $value => $expected) {
$result = get_offset_sec($value);
$this->assertEquals($expected, $result, "Invalid get_offset_sec() result for {$value}");
}
}
开发者ID:netcon-source,项目名称:roundcubemail,代码行数:11,代码来源:Shared.php
示例3: get_offset_time
/**
* Create a unix timestamp with a specified offset from now.
*
* @param string $offset_str String representation of the offset (e.g. 20min, 5h, 2days)
* @param int $factor Factor to multiply with the offset
*
* @return int Unix timestamp
*/
function get_offset_time($offset_str, $factor = 1)
{
return time() + get_offset_sec($offset_str) * $factor;
}
开发者ID:NathanAUS,项目名称:roundcubemail,代码行数:12,代码来源:bootstrap.php
示例4: __construct
/**
* Object constructor.
*
* @param rcube_db $db DB handler
* @param rcube_imap $imap IMAP handler
* @param int $userid User identifier
* @param bool $skip_deleted skip_deleted flag
* @param string $ttl Expiration time of memcache/apc items
* @param int $threshold Maximum cached message size
*/
function __construct($db, $imap, $userid, $skip_deleted, $ttl = 0, $threshold = 0)
{
// convert ttl string to seconds
$ttl = get_offset_sec($ttl);
if ($ttl > 2592000) {
$ttl = 2592000;
}
$this->db = $db;
$this->imap = $imap;
$this->userid = $userid;
$this->skip_deleted = $skip_deleted;
$this->ttl = $ttl;
$this->threshold = $threshold;
// cache all possible information by default
$this->mode = self::MODE_INDEX | self::MODE_MESSAGE;
// database tables
$this->index_table = $db->table_name('cache_index', true);
$this->thread_table = $db->table_name('cache_thread', true);
$this->messages_table = $db->table_name('cache_messages', true);
}
开发者ID:JotapePinheiro,项目名称:roundcubemail,代码行数:30,代码来源:rcube_imap_cache.php
示例5: gc_temp
/**
* Garbage collector function for temp files.
* Remove temp files older than two days
*/
public function gc_temp()
{
$tmp = unslashify($this->config->get('temp_dir'));
// expire in 48 hours by default
$temp_dir_ttl = $this->config->get('temp_dir_ttl', '48h');
$temp_dir_ttl = get_offset_sec($temp_dir_ttl);
if ($temp_dir_ttl < 6 * 3600) {
$temp_dir_ttl = 6 * 3600;
}
// 6 hours sensible lower bound.
$expire = time() - $temp_dir_ttl;
if ($tmp && ($dir = opendir($tmp))) {
while (($fname = readdir($dir)) !== false) {
if ($fname[0] == '.') {
continue;
}
if (@filemtime($tmp . '/' . $fname) < $expire) {
@unlink($tmp . '/' . $fname);
}
}
closedir($dir);
}
}
开发者ID:neynah,项目名称:roundcubemail,代码行数:27,代码来源:rcube.php
示例6: __construct
/**
* Object constructor.
*
* @param rcube_db $db DB handler
* @param rcube_imap $imap IMAP handler
* @param int $userid User identifier
* @param bool $skip_deleted skip_deleted flag
* @param string $ttl Expiration time of memcache/apc items
* @param int $threshold Maximum cached message size
*/
function __construct($db, $imap, $userid, $skip_deleted, $ttl = 0, $threshold = 0)
{
// convert ttl string to seconds
$ttl = get_offset_sec($ttl);
if ($ttl > 2592000) {
$ttl = 2592000;
}
$this->db = $db;
$this->imap = $imap;
$this->userid = $userid;
$this->skip_deleted = $skip_deleted;
$this->ttl = $ttl;
$this->threshold = $threshold;
// cache all possible information by default
$this->mode = self::MODE_INDEX | self::MODE_MESSAGE;
}
开发者ID:zamentur,项目名称:roundcube_ynh,代码行数:26,代码来源:rcube_imap_cache.php
注:本文中的get_offset_sec函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论