Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
fcf2d0a3
Commit
fcf2d0a3
authored
Mar 22, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #2823.
parent
6e8c4602
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
94 additions
and
119 deletions
+94
-119
ApcCache.php
framework/caching/ApcCache.php
+12
-12
Cache.php
framework/caching/Cache.php
+23
-23
DbCache.php
framework/caching/DbCache.php
+7
-13
DummyCache.php
framework/caching/DummyCache.php
+4
-4
FileCache.php
framework/caching/FileCache.php
+14
-17
MemCache.php
framework/caching/MemCache.php
+10
-26
WinCache.php
framework/caching/WinCache.php
+12
-12
XCache.php
framework/caching/XCache.php
+6
-6
ZendDataCache.php
framework/caching/ZendDataCache.php
+6
-6
No files found.
framework/caching/ApcCache.php
View file @
fcf2d0a3
...
...
@@ -64,23 +64,23 @@ class ApcCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
setValue
(
$key
,
$value
,
$
expire
)
protected
function
setValue
(
$key
,
$value
,
$
duration
)
{
return
apc_store
(
$key
,
$value
,
$
expire
);
return
apc_store
(
$key
,
$value
,
$
duration
);
}
/**
* Stores multiple key-value pairs in cache.
* @param array $data array where key corresponds to cache key while value
* @param integer $
expire
the number of seconds in which the cached values will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached values will expire. 0 means never expire.
* @return array array of failed keys
*/
protected
function
setValues
(
$data
,
$
expire
)
protected
function
setValues
(
$data
,
$
duration
)
{
return
array_keys
(
apc_store
(
$data
,
null
,
$
expire
));
return
array_keys
(
apc_store
(
$data
,
null
,
$
duration
));
}
/**
...
...
@@ -88,23 +88,23 @@ class ApcCache extends Cache
* This is the implementation of the method declared in the parent class.
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
addValue
(
$key
,
$value
,
$
expire
)
protected
function
addValue
(
$key
,
$value
,
$
duration
)
{
return
apc_add
(
$key
,
$value
,
$
expire
);
return
apc_add
(
$key
,
$value
,
$
duration
);
}
/**
* Adds multiple key-value pairs to cache.
* @param array $data array where key corresponds to cache key while value is the value stored
* @param integer $
expire
the number of seconds in which the cached values will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached values will expire. 0 means never expire.
* @return array array of failed keys
*/
protected
function
addValues
(
$data
,
$
expire
)
protected
function
addValues
(
$data
,
$
duration
)
{
return
array_keys
(
apc_add
(
$data
,
null
,
$
expire
));
return
array_keys
(
apc_add
(
$data
,
null
,
$
duration
));
}
/**
...
...
framework/caching/Cache.php
View file @
fcf2d0a3
...
...
@@ -27,7 +27,7 @@ use yii\helpers\StringHelper;
* $data = $cache->get($key);
* if ($data === false) {
* // ...generate $data here...
* $cache->set($key, $data, $
expire
, $dependency);
* $cache->set($key, $data, $
duration
, $dependency);
* }
* ~~~
*
...
...
@@ -194,13 +194,13 @@ abstract class Cache extends Component implements \ArrayAccess
* @param mixed $key a key identifying the value to be cached. This can be a simple string or
* a complex data structure consisting of factors representing the key.
* @param mixed $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @param Dependency $dependency dependency of the cached item. If the dependency changes,
* the corresponding value in the cache will be invalidated when it is fetched via [[get()]].
* This parameter is ignored if [[serializer]] is false.
* @return boolean whether the value is successfully stored into cache
*/
public
function
set
(
$key
,
$value
,
$
expire
=
0
,
$dependency
=
null
)
public
function
set
(
$key
,
$value
,
$
duration
=
0
,
$dependency
=
null
)
{
if
(
$dependency
!==
null
&&
$this
->
serializer
!==
false
)
{
$dependency
->
evaluateDependency
(
$this
);
...
...
@@ -212,7 +212,7 @@ abstract class Cache extends Component implements \ArrayAccess
}
$key
=
$this
->
buildKey
(
$key
);
return
$this
->
setValue
(
$key
,
$value
,
$
expire
);
return
$this
->
setValue
(
$key
,
$value
,
$
duration
);
}
/**
...
...
@@ -221,13 +221,13 @@ abstract class Cache extends Component implements \ArrayAccess
* expiration time will be replaced with the new ones, respectively.
*
* @param array $items the items to be cached, as key-value pairs.
* @param integer $
expire
default number of seconds in which the cached values will expire. 0 means never expire.
* @param integer $
duration
default number of seconds in which the cached values will expire. 0 means never expire.
* @param Dependency $dependency dependency of the cached items. If the dependency changes,
* the corresponding values in the cache will be invalidated when it is fetched via [[get()]].
* This parameter is ignored if [[serializer]] is false.
* @return boolean whether the items are successfully stored into cache
*/
public
function
mset
(
$items
,
$
expire
=
0
,
$dependency
=
null
)
public
function
mset
(
$items
,
$
duration
=
0
,
$dependency
=
null
)
{
if
(
$dependency
!==
null
&&
$this
->
serializer
!==
false
)
{
$dependency
->
evaluateDependency
(
$this
);
...
...
@@ -245,7 +245,7 @@ abstract class Cache extends Component implements \ArrayAccess
$data
[
$key
]
=
$value
;
}
return
$this
->
setValues
(
$data
,
$
expire
);
return
$this
->
setValues
(
$data
,
$
duration
);
}
/**
...
...
@@ -253,13 +253,13 @@ abstract class Cache extends Component implements \ArrayAccess
* If the cache already contains such a key, the existing value and expiration time will be preserved.
*
* @param array $items the items to be cached, as key-value pairs.
* @param integer $
expire
default number of seconds in which the cached values will expire. 0 means never expire.
* @param integer $
duration
default number of seconds in which the cached values will expire. 0 means never expire.
* @param Dependency $dependency dependency of the cached items. If the dependency changes,
* the corresponding values in the cache will be invalidated when it is fetched via [[get()]].
* This parameter is ignored if [[serializer]] is false.
* @return boolean whether the items are successfully stored into cache
*/
public
function
madd
(
$items
,
$
expire
=
0
,
$dependency
=
null
)
public
function
madd
(
$items
,
$
duration
=
0
,
$dependency
=
null
)
{
if
(
$dependency
!==
null
&&
$this
->
serializer
!==
false
)
{
$dependency
->
evaluateDependency
(
$this
);
...
...
@@ -277,7 +277,7 @@ abstract class Cache extends Component implements \ArrayAccess
$data
[
$key
]
=
$value
;
}
return
$this
->
addValues
(
$data
,
$
expire
);
return
$this
->
addValues
(
$data
,
$
duration
);
}
/**
...
...
@@ -286,13 +286,13 @@ abstract class Cache extends Component implements \ArrayAccess
* @param mixed $key a key identifying the value to be cached. This can be a simple string or
* a complex data structure consisting of factors representing the key.
* @param mixed $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @param Dependency $dependency dependency of the cached item. If the dependency changes,
* the corresponding value in the cache will be invalidated when it is fetched via [[get()]].
* This parameter is ignored if [[serializer]] is false.
* @return boolean whether the value is successfully stored into cache
*/
public
function
add
(
$key
,
$value
,
$
expire
=
0
,
$dependency
=
null
)
public
function
add
(
$key
,
$value
,
$
duration
=
0
,
$dependency
=
null
)
{
if
(
$dependency
!==
null
&&
$this
->
serializer
!==
false
)
{
$dependency
->
evaluateDependency
(
$this
);
...
...
@@ -304,7 +304,7 @@ abstract class Cache extends Component implements \ArrayAccess
}
$key
=
$this
->
buildKey
(
$key
);
return
$this
->
addValue
(
$key
,
$value
,
$
expire
);
return
$this
->
addValue
(
$key
,
$value
,
$
duration
);
}
/**
...
...
@@ -345,10 +345,10 @@ abstract class Cache extends Component implements \ArrayAccess
* in specific cache storage.
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
abstract
protected
function
setValue
(
$key
,
$value
,
$
expire
);
abstract
protected
function
setValue
(
$key
,
$value
,
$
duration
);
/**
* Stores a value identified by a key into cache if the cache does not contain this key.
...
...
@@ -356,10 +356,10 @@ abstract class Cache extends Component implements \ArrayAccess
* in specific cache storage.
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
abstract
protected
function
addValue
(
$key
,
$value
,
$
expire
);
abstract
protected
function
addValue
(
$key
,
$value
,
$
duration
);
/**
* Deletes a value with the specified key from cache
...
...
@@ -399,14 +399,14 @@ abstract class Cache extends Component implements \ArrayAccess
* The default implementation calls [[setValue()]] multiple times store values one by one. If the underlying cache
* storage supports multi-set, this method should be overridden to exploit that feature.
* @param array $data array where key corresponds to cache key while value is the value stored
* @param integer $
expire
the number of seconds in which the cached values will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached values will expire. 0 means never expire.
* @return array array of failed keys
*/
protected
function
setValues
(
$data
,
$
expire
)
protected
function
setValues
(
$data
,
$
duration
)
{
$failedKeys
=
[];
foreach
(
$data
as
$key
=>
$value
)
{
if
(
$this
->
setValue
(
$key
,
$value
,
$
expire
)
===
false
)
{
if
(
$this
->
setValue
(
$key
,
$value
,
$
duration
)
===
false
)
{
$failedKeys
[]
=
$key
;
}
}
...
...
@@ -419,14 +419,14 @@ abstract class Cache extends Component implements \ArrayAccess
* The default implementation calls [[addValue()]] multiple times add values one by one. If the underlying cache
* storage supports multi-add, this method should be overridden to exploit that feature.
* @param array $data array where key corresponds to cache key while value is the value stored
* @param integer $
expire
the number of seconds in which the cached values will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached values will expire. 0 means never expire.
* @return array array of failed keys
*/
protected
function
addValues
(
$data
,
$
expire
)
protected
function
addValues
(
$data
,
$
duration
)
{
$failedKeys
=
[];
foreach
(
$data
as
$key
=>
$value
)
{
if
(
$this
->
addValue
(
$key
,
$value
,
$
expire
)
===
false
)
{
if
(
$this
->
addValue
(
$key
,
$value
,
$
duration
)
===
false
)
{
$failedKeys
[]
=
$key
;
}
}
...
...
framework/caching/DbCache.php
View file @
fcf2d0a3
...
...
@@ -178,14 +178,14 @@ class DbCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
setValue
(
$key
,
$value
,
$
expire
)
protected
function
setValue
(
$key
,
$value
,
$
duration
)
{
$command
=
$this
->
db
->
createCommand
()
->
update
(
$this
->
cacheTable
,
[
'expire'
=>
$
expire
>
0
?
$expire
+
time
()
:
0
,
'expire'
=>
$
duration
>
0
?
$duration
+
time
()
:
0
,
'data'
=>
[
$value
,
\PDO
::
PARAM_LOB
],
],
[
'id'
=>
$key
]);
...
...
@@ -194,7 +194,7 @@ class DbCache extends Cache
return
true
;
}
else
{
return
$this
->
addValue
(
$key
,
$value
,
$
expire
);
return
$this
->
addValue
(
$key
,
$value
,
$
duration
);
}
}
...
...
@@ -204,24 +204,18 @@ class DbCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
addValue
(
$key
,
$value
,
$
expire
)
protected
function
addValue
(
$key
,
$value
,
$
duration
)
{
$this
->
gc
();
if
(
$expire
>
0
)
{
$expire
+=
time
();
}
else
{
$expire
=
0
;
}
try
{
$this
->
db
->
createCommand
()
->
insert
(
$this
->
cacheTable
,
[
'id'
=>
$key
,
'expire'
=>
$
expire
,
'expire'
=>
$
duration
>
0
?
$duration
+
time
()
:
0
,
'data'
=>
[
$value
,
\PDO
::
PARAM_LOB
],
])
->
execute
();
...
...
framework/caching/DummyCache.php
View file @
fcf2d0a3
...
...
@@ -37,10 +37,10 @@ class DummyCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
setValue
(
$key
,
$value
,
$
expire
)
protected
function
setValue
(
$key
,
$value
,
$
duration
)
{
return
true
;
}
...
...
@@ -50,10 +50,10 @@ class DummyCache extends Cache
* This is the implementation of the method declared in the parent class.
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
addValue
(
$key
,
$value
,
$
expire
)
protected
function
addValue
(
$key
,
$value
,
$
duration
)
{
return
true
;
}
...
...
framework/caching/FileCache.php
View file @
fcf2d0a3
...
...
@@ -119,16 +119,11 @@ class FileCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
setValue
(
$key
,
$value
,
$
expire
)
protected
function
setValue
(
$key
,
$value
,
$
duration
)
{
if
(
$expire
<=
0
)
{
$expire
=
31536000
;
// 1 year
}
$expire
+=
time
();
$cacheFile
=
$this
->
getCacheFile
(
$key
);
if
(
$this
->
directoryLevel
>
0
)
{
@
FileHelper
::
createDirectory
(
dirname
(
$cacheFile
),
$this
->
dirMode
,
true
);
...
...
@@ -137,8 +132,10 @@ class FileCache extends Cache
if
(
$this
->
fileMode
!==
null
)
{
@
chmod
(
$cacheFile
,
$this
->
fileMode
);
}
return
@
touch
(
$cacheFile
,
$expire
);
if
(
$duration
<=
0
)
{
$duration
=
31536000
;
// 1 year
}
return
@
touch
(
$cacheFile
,
$duration
+
time
());
}
else
{
return
false
;
}
...
...
@@ -150,17 +147,17 @@ class FileCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
addValue
(
$key
,
$value
,
$
expire
)
protected
function
addValue
(
$key
,
$value
,
$
duration
)
{
$cacheFile
=
$this
->
getCacheFile
(
$key
);
if
(
@
filemtime
(
$cacheFile
)
>
time
())
{
return
false
;
}
return
$this
->
setValue
(
$key
,
$value
,
$
expire
);
return
$this
->
setValue
(
$key
,
$value
,
$
duration
);
}
/**
...
...
@@ -227,10 +224,10 @@ class FileCache extends Cache
* Recursively removing expired cache files under a directory.
* This method is mainly used by [[gc()]].
* @param string $path the directory under which expired cache files are removed.
* @param boolean $
expire
dOnly whether to only remove expired cache files. If false, all files
* @param boolean $
duration
dOnly whether to only remove expired cache files. If false, all files
* under `$path` will be removed.
*/
protected
function
gcRecursive
(
$path
,
$
expire
dOnly
)
protected
function
gcRecursive
(
$path
,
$
duration
dOnly
)
{
if
((
$handle
=
opendir
(
$path
))
!==
false
)
{
while
((
$file
=
readdir
(
$handle
))
!==
false
)
{
...
...
@@ -239,11 +236,11 @@ class FileCache extends Cache
}
$fullPath
=
$path
.
DIRECTORY_SEPARATOR
.
$file
;
if
(
is_dir
(
$fullPath
))
{
$this
->
gcRecursive
(
$fullPath
,
$
expire
dOnly
);
if
(
!
$
expire
dOnly
)
{
$this
->
gcRecursive
(
$fullPath
,
$
duration
dOnly
);
if
(
!
$
duration
dOnly
)
{
@
rmdir
(
$fullPath
);
}
}
elseif
(
!
$
expiredOnly
||
$expire
dOnly
&&
@
filemtime
(
$fullPath
)
<
time
())
{
}
elseif
(
!
$
durationdOnly
||
$duration
dOnly
&&
@
filemtime
(
$fullPath
)
<
time
())
{
@
unlink
(
$fullPath
);
}
}
...
...
framework/caching/MemCache.php
View file @
fcf2d0a3
...
...
@@ -188,39 +188,28 @@ class MemCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
setValue
(
$key
,
$value
,
$
expire
)
protected
function
setValue
(
$key
,
$value
,
$
duration
)
{
if
(
$expire
>
0
)
{
$expire
+=
time
();
}
else
{
$expire
=
0
;
}
$expire
=
$duration
>
0
?
$duration
+
time
()
:
0
;
return
$this
->
useMemcached
?
$this
->
_cache
->
set
(
$key
,
$value
,
$expire
)
:
$this
->
_cache
->
set
(
$key
,
$value
,
0
,
$expire
);
}
/**
* Stores multiple key-value pairs in cache.
* @param array $data array where key corresponds to cache key while value is the value stored
* @param integer $
expire
the number of seconds in which the cached values will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached values will expire. 0 means never expire.
* @return array array of failed keys. Always empty in case of using memcached.
*/
protected
function
setValues
(
$data
,
$
expire
)
protected
function
setValues
(
$data
,
$
duration
)
{
if
(
$this
->
useMemcached
)
{
if
(
$expire
>
0
)
{
$expire
+=
time
();
}
else
{
$expire
=
0
;
}
$this
->
_cache
->
setMulti
(
$data
,
$expire
);
$this
->
_cache
->
setMulti
(
$data
,
$duration
>
0
?
$duration
+
time
()
:
0
);
return
[];
}
else
{
return
parent
::
setValues
(
$data
,
$
expire
);
return
parent
::
setValues
(
$data
,
$
duration
);
}
}
...
...
@@ -230,17 +219,12 @@ class MemCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
addValue
(
$key
,
$value
,
$
expire
)
protected
function
addValue
(
$key
,
$value
,
$
duration
)
{
if
(
$expire
>
0
)
{
$expire
+=
time
();
}
else
{
$expire
=
0
;
}
$expire
=
$duration
>
0
?
$duration
+
time
()
:
0
;
return
$this
->
useMemcached
?
$this
->
_cache
->
add
(
$key
,
$value
,
$expire
)
:
$this
->
_cache
->
add
(
$key
,
$value
,
0
,
$expire
);
}
...
...
framework/caching/WinCache.php
View file @
fcf2d0a3
...
...
@@ -64,23 +64,23 @@ class WinCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
setValue
(
$key
,
$value
,
$
expire
)
protected
function
setValue
(
$key
,
$value
,
$
duration
)
{
return
wincache_ucache_set
(
$key
,
$value
,
$
expire
);
return
wincache_ucache_set
(
$key
,
$value
,
$
duration
);
}
/**
* Stores multiple key-value pairs in cache.
* @param array $data array where key corresponds to cache key while value is the value stored
* @param integer $
expire
the number of seconds in which the cached values will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached values will expire. 0 means never expire.
* @return array array of failed keys
*/
protected
function
setValues
(
$data
,
$
expire
)
protected
function
setValues
(
$data
,
$
duration
)
{
return
wincache_ucache_set
(
$data
,
null
,
$
expire
);
return
wincache_ucache_set
(
$data
,
null
,
$
duration
);
}
/**
...
...
@@ -89,12 +89,12 @@ class WinCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
addValue
(
$key
,
$value
,
$
expire
)
protected
function
addValue
(
$key
,
$value
,
$
duration
)
{
return
wincache_ucache_add
(
$key
,
$value
,
$
expire
);
return
wincache_ucache_add
(
$key
,
$value
,
$
duration
);
}
/**
...
...
@@ -102,12 +102,12 @@ class WinCache extends Cache
* The default implementation calls [[addValue()]] multiple times add values one by one. If the underlying cache
* storage supports multiadd, this method should be overridden to exploit that feature.
* @param array $data array where key corresponds to cache key while value is the value stored
* @param integer $
expire
the number of seconds in which the cached values will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached values will expire. 0 means never expire.
* @return array array of failed keys
*/
protected
function
addValues
(
$data
,
$
expire
)
protected
function
addValues
(
$data
,
$
duration
)
{
return
wincache_ucache_add
(
$data
,
null
,
$
expire
);
return
wincache_ucache_add
(
$data
,
null
,
$
duration
);
}
/**
...
...
framework/caching/XCache.php
View file @
fcf2d0a3
...
...
@@ -55,12 +55,12 @@ class XCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
setValue
(
$key
,
$value
,
$
expire
)
protected
function
setValue
(
$key
,
$value
,
$
duration
)
{
return
xcache_set
(
$key
,
$value
,
$
expire
);
return
xcache_set
(
$key
,
$value
,
$
duration
);
}
/**
...
...
@@ -69,12 +69,12 @@ class XCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
addValue
(
$key
,
$value
,
$
expire
)
protected
function
addValue
(
$key
,
$value
,
$
duration
)
{
return
!
xcache_isset
(
$key
)
?
$this
->
setValue
(
$key
,
$value
,
$
expire
)
:
false
;
return
!
xcache_isset
(
$key
)
?
$this
->
setValue
(
$key
,
$value
,
$
duration
)
:
false
;
}
/**
...
...
framework/caching/ZendDataCache.php
View file @
fcf2d0a3
...
...
@@ -39,12 +39,12 @@ class ZendDataCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
setValue
(
$key
,
$value
,
$
expire
)
protected
function
setValue
(
$key
,
$value
,
$
duration
)
{
return
zend_shm_cache_store
(
$key
,
$value
,
$
expire
);
return
zend_shm_cache_store
(
$key
,
$value
,
$
duration
);
}
/**
...
...
@@ -53,12 +53,12 @@ class ZendDataCache extends Cache
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $
expire
the number of seconds in which the cached value will expire. 0 means never expire.
* @param integer $
duration
the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected
function
addValue
(
$key
,
$value
,
$
expire
)
protected
function
addValue
(
$key
,
$value
,
$
duration
)
{
return
zend_shm_cache_fetch
(
$key
)
===
null
?
$this
->
setValue
(
$key
,
$value
,
$
expire
)
:
false
;
return
zend_shm_cache_fetch
(
$key
)
===
null
?
$this
->
setValue
(
$key
,
$value
,
$
duration
)
:
false
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment