Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
FlowObjectCache
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 6
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 get
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getMulti
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 set
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 delete
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 makeGlobalKey
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Flow\Data;
4
5use Flow\DbFactory;
6use WANObjectCache;
7use Wikimedia\Rdbms\Database;
8
9class FlowObjectCache {
10    /**
11     * @var WANObjectCache
12     */
13    protected $cache;
14
15    /**
16     * @var int
17     */
18    protected $ttl = 0;
19
20    /**
21     * @var array
22     */
23    protected $setOptions;
24
25    /**
26     * @param WANObjectCache $cache The cache implementation to back this buffer with
27     * @param DbFactory $dbFactory
28     * @param int $ttl The default length of time to cache data. 0 for LRU.
29     */
30    public function __construct( WANObjectCache $cache, DbFactory $dbFactory, $ttl = 0 ) {
31        $this->ttl = $ttl;
32        $this->cache = $cache;
33        $this->setOptions = Database::getCacheSetOptions( $dbFactory->getDB( DB_REPLICA ) );
34    }
35
36    /**
37     * @param string $key
38     * @return mixed
39     */
40    public function get( $key ) {
41        return $this->cache->get( $key );
42    }
43
44    /**
45     * @param array $keys
46     * @return array
47     */
48    public function getMulti( array $keys ) {
49        return $this->cache->getMulti( $keys );
50    }
51
52    /**
53     * @param string $key
54     * @param mixed $value
55     * @return bool
56     */
57    public function set( $key, $value ) {
58        return $this->cache->set( $key, $value, $this->ttl, $this->setOptions );
59    }
60
61    /**
62     * @param string $key
63     * @return bool
64     */
65    public function delete( $key ) {
66        return $this->cache->delete( $key );
67    }
68
69    /**
70     * @param string $class
71     * @param string|int ...$components
72     * @return string
73     */
74    public function makeGlobalKey( $class, ...$components ) {
75        return $this->cache->makeGlobalKey( $class, ...$components );
76    }
77}