4
4
* See COPYING.txt for license details.
5
5
*/
6
6
7
- // @codingStandardsIgnoreFile
8
-
9
7
/**
10
- Tables declaration:
11
-
12
- CREATE TABLE IF NOT EXISTS `cache` (
13
- `id` VARCHAR(255) NOT NULL,
14
- `data` mediumblob,
15
- `create_time` int(11),
16
- `update_time` int(11),
17
- `expire_time` int(11),
18
- PRIMARY KEY (`id`),
19
- KEY `IDX_EXPIRE_TIME` (`expire_time`)
20
- )ENGINE=InnoDB DEFAULT CHARSET=utf8;
21
-
22
- CREATE TABLE IF NOT EXISTS `cache_tag` (
23
- `tag` VARCHAR(255) NOT NULL,
24
- `cache_id` VARCHAR(255) NOT NULL,
25
- KEY `IDX_TAG` (`tag`),
26
- KEY `IDX_CACHE_ID` (`cache_id`),
27
- CONSTRAINT `FK_CORE_CACHE_TAG` FOREIGN KEY (`cache_id`) REFERENCES `cache` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
28
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
29
- */
8
+ * Tables declaration:
9
+ *
10
+ * CREATE TABLE IF NOT EXISTS `cache` (
11
+ * `id` VARCHAR(255) NOT NULL,
12
+ * `data` mediumblob,
13
+ * `create_time` int(11),
14
+ * `update_time` int(11),
15
+ * `expire_time` int(11),
16
+ * PRIMARY KEY (`id`),
17
+ * KEY `IDX_EXPIRE_TIME` (`expire_time`)
18
+ * )ENGINE=InnoDB DEFAULT CHARSET=utf8;
19
+ *
20
+ * CREATE TABLE IF NOT EXISTS `cache_tag` (
21
+ * `tag` VARCHAR(255) NOT NULL,
22
+ * `cache_id` VARCHAR(255) NOT NULL,
23
+ * KEY `IDX_TAG` (`tag`),
24
+ * KEY `IDX_CACHE_ID` (`cache_id`),
25
+ * CONSTRAINT `FK_CORE_CACHE_TAG` FOREIGN KEY (`cache_id`)
26
+ * REFERENCES `cache` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
27
+ * ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
28
+ */
30
29
31
30
/**
32
31
* Database cache backend
@@ -148,7 +147,10 @@ public function load($id, $doNotTestCacheValidity = false)
148
147
{
149
148
if ($ this ->_options ['store_data ' ] && !$ this ->_options ['infinite_loop_flag ' ]) {
150
149
$ this ->_options ['infinite_loop_flag ' ] = true ;
151
- $ select = $ this ->_getConnection ()->select ()->from ($ this ->_getDataTable (), 'data ' )->where ('id=:cache_id ' );
150
+ $ select = $ this ->_getConnection ()->select ()->from (
151
+ $ this ->_getDataTable (),
152
+ 'data '
153
+ )->where ('id=:cache_id ' );
152
154
153
155
if (!$ doNotTestCacheValidity ) {
154
156
$ select ->where ('expire_time=0 OR expire_time>? ' , time ());
@@ -197,7 +199,7 @@ public function test($id)
197
199
* @param string $data Datas to cache
198
200
* @param string $id Cache id
199
201
* @param string[] $tags Array of strings, the cache record will be tagged by each string entry
200
- * @param int|bool $specificLifetime If != false, set a specific lifetime for this cache record ( null => infinite lifetime)
202
+ * @param int|bool $specificLifetime Integer to set a specific lifetime or null for infinite lifetime
201
203
* @return bool true if no problem
202
204
*/
203
205
public function save ($ data , $ id , $ tags = [], $ specificLifetime = false )
@@ -222,7 +224,8 @@ public function save($data, $id, $tags = [], $specificLifetime = false)
222
224
'create_time '
223
225
)}, \n {$ connection ->quoteIdentifier (
224
226
'update_time '
225
- )}, \n {$ expireCol }) \n VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE \n {$ dataCol }=VALUES( {$ dataCol }), \n {$ expireCol }=VALUES( {$ expireCol }) " ;
227
+ )}, \n {$ expireCol }) \n VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE \n
228
+ {$ dataCol }=VALUES( {$ dataCol }), \n {$ expireCol }=VALUES( {$ expireCol }) " ;
226
229
227
230
$ result = $ connection ->query ($ query , [$ id , $ data , $ time , $ time , $ expire ])->rowCount ();
228
231
}
@@ -554,10 +557,10 @@ protected function _cleanByTags($mode, $tags)
554
557
/**
555
558
* Clean all cache entries
556
559
*
557
- * @param $connection
560
+ * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
558
561
* @return bool
559
562
*/
560
- private function cleanAll ($ connection )
563
+ private function cleanAll (\ Magento \ Framework \ DB \ Adapter \ AdapterInterface $ connection )
561
564
{
562
565
if ($ this ->_options ['store_data ' ]) {
563
566
$ result = $ connection ->query ('TRUNCATE TABLE ' . $ this ->_getDataTable ());
@@ -571,10 +574,10 @@ private function cleanAll($connection)
571
574
/**
572
575
* Clean old cache entries
573
576
*
574
- * @param $connection
577
+ * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
575
578
* @return bool
576
579
*/
577
- private function cleanOld ($ connection )
580
+ private function cleanOld (\ Magento \ Framework \ DB \ Adapter \ AdapterInterface $ connection )
578
581
{
579
582
if ($ this ->_options ['store_data ' ]) {
580
583
$ result = $ connection ->delete (
0 commit comments