Completed
Push — release-2.1 ( 4bdd41...11eb43 )
by Mathias
07:36
created

zend_cache::getVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Simple Machines Forum (SMF)
5
 *
6
 * @package SMF
7
 * @author Simple Machines http://www.simplemachines.org
8
 * @copyright 2017 Simple Machines and individual contributors
9
 * @license http://www.simplemachines.org/about/smf/license.php BSD
10
 *
11
 * @version 2.1 Beta 4
12
 */
13
14
if (!defined('SMF'))
15
	die('Hacking attempt...');
16
17
/**
18
 * Our Cache API class
19
 * @package cacheAPI
20
 */
21
class zend_cache extends cache_api
22
{
23
	/**
24
	 * {@inheritDoc}
25
	 */
26
	public function isSupported($test = false)
27
	{
28
		$supported = function_exists('zend_shm_cache_fetch') || function_exists('output_cache_get');
29
30
		if ($test)
31
			return $supported;
32
		return parent::isSupported() && $supported;
33
	}
34
35
	/**
36
	 * {@inheritDoc}
37
	 */
38 View Code Duplication
	public function getData($key, $ttl = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
	{
40
		$key = $this->prefix . strtr($key, ':/', '-_');
41
42
		// Zend's pricey stuff.
43
		if (function_exists('zend_shm_cache_fetch'))
44
			return zend_shm_cache_fetch('SMF::' . $key);
45
		elseif (function_exists('output_cache_get'))
46
			return output_cache_get($key, $ttl);
47
	}
48
49
	/**
50
	 * {@inheritDoc}
51
	 */
52 View Code Duplication
	public function putData($key, $value, $ttl = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
	{
54
		$key = $this->prefix . strtr($key, ':/', '-_');
55
56
		if (function_exists('zend_shm_cache_store'))
57
			return zend_shm_cache_store('SMF::' . $key, $value, $ttl);
58
		elseif (function_exists('output_cache_put'))
59
			return output_cache_put($key, $value);
60
	}
61
62
	/**
63
	 * {@inheritDoc}
64
	 */
65
	public function cleanCache($type = '')
66
	{
67
		$this->invalidateCache();
68
69
		return zend_shm_cache_clear('SMF');
70
	}
71
72
	/**
73
	 * {@inheritDoc}
74
	 */
75
	public function getVersion()
76
	{
77
		return zend_version();
78
	}
79
}
80
81
?>