Completed
Push — master ( dd4d74...24ba14 )
by Da Phuture
10:51 queued 05:05
created

ApcStorage::has()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Kemist\Cache\Storage;
4
5
/**
6
 * ApcStorage
7
 * 
8
 * @package Kemist\Cache
9
 * 
10
 * @version 1.0.10
11
 */
12
class ApcStorage extends AbstractStorage implements StorageInterface {
13
14
  /**
15
   * Constructor
16
   * 
17
   * @param array $options
18
   */
19
  public function __construct(ApcObject $apc, array $options = array()) {
20
    $this->prefix = (isset($options['prefix']) ? $options['prefix'] : '');
21
    $this->provider = $apc;
22
  }
23
24
  /**
25
   * Initialise Cache storage
26
   * 
27
   * @return boolean
28
   * 
29
   * @throws \Kemist\Cache\Exception
30
   */
31
  public function init() {
32
    return true;
33
  }
34
35
  /**
36
   * Checks if the specified name in cache exists
37
   * 	 
38
   * @param string $name cache name
39
   *
40
   * @return bool
41
   */
42
  public function has($name) {
43
    if ($this->provider->get($this->prefix . $name)) {
44
      return true;
45
    }
46
    return false;
47
  }
48
49
  /**
50
   * Saves the variable to the $name cache
51
   * 	 
52
   * @param string $name cache name
53
   * @param mixed $val variable to be stored
54
   *
55
   * @return bool
56
   */
57
  public function store($name, $val, $compressed = false) {
58
    $success = $this->provider->store($this->prefix . $name, $val);
59
    $success ? $this->storeName($name) : null;
60
    return $success;
61
  }
62
63
}
64