1 | <?php |
||
21 | class Mysql |
||
22 | extends \Aimeos\MW\Cache\DB |
||
|
|||
23 | implements \Aimeos\MW\Cache\Iface |
||
24 | { |
||
25 | private $sql; |
||
26 | private $dbm; |
||
27 | private $dbname; |
||
28 | private $siteid; |
||
29 | |||
30 | |||
31 | /** |
||
32 | * Initializes the object instance. |
||
33 | * |
||
34 | * The config['search] array must contain these key/array pairs suitable for \Aimeos\MW\Criteria\Attribute\Standard: |
||
35 | * [cache.id] => Array containing the codes/types/labels for the unique ID |
||
36 | * [cache.siteid] => Array containing the codes/types/labels for the site ID |
||
37 | * [cache.value] => Array containing the codes/types/labels for the cached value |
||
38 | * [cache.expire] => Array containing the codes/types/labels for the expiration date |
||
39 | * [cache.tag.name] => Array containing the codes/types/labels for the tag name |
||
40 | * |
||
41 | * The config['sql] array must contain these statement: |
||
42 | * [delete] => |
||
43 | * DELETE FROM cachetable WHERE siteid = ? AND :cond |
||
44 | * [deletebytag] => |
||
45 | * DELETE FROM cachetable WHERE siteid = ? AND id IN ( |
||
46 | * SELECT tid FROM cachetagtable WHERE tsiteid = ? AND :cond |
||
47 | * ) |
||
48 | * [get] => |
||
49 | * SELECT id, value, expire FROM cachetable WHERE siteid = ? AND :cond |
||
50 | * [getbytag] => |
||
51 | * SELECT id, value, expire FROM cachetable |
||
52 | * JOIN cachetagtable ON tid = id |
||
53 | * WHERE siteid = ? AND tsiteid = ? AND :cond |
||
54 | * [set] => |
||
55 | * INSERT INTO cachetable ( id, siteid, expire, value ) VALUES ( ?, ?, ?, ? ) ON DUPLICATE KEY UPDATE |
||
56 | * [settag] => |
||
57 | * INSERT INTO cachetagtable ( tid, tsiteid, tname ) VALUES :tuples ON DUPLICATE KEY UPDATE |
||
58 | * |
||
59 | * For using a different database connection, the name of the database connection |
||
60 | * can be also given in the "config" parameter. In this case, use e.g. |
||
61 | * config['dbname'] = 'db-cache' |
||
62 | * |
||
63 | * If a site ID is given, the cache is partitioned for different |
||
64 | * sites. This also includes access control so cached values can be only |
||
65 | * retrieved from the same site. Specify a site ID with |
||
66 | * config['siteid'] = 123 |
||
67 | * |
||
68 | * @param array $config Associative list with SQL statements, search attribute definitions and database name |
||
69 | * @param \Aimeos\MW\DB\Manager\Iface $dbm Database manager |
||
70 | */ |
||
71 | public function __construct( array $config, \Aimeos\MW\DB\Manager\Iface $dbm ) |
||
80 | |||
81 | |||
82 | /** |
||
83 | * Adds or overwrites the given key/value pairs in the cache, which is much |
||
84 | * more efficient than setting them one by one using the set() method. |
||
85 | * |
||
86 | * @param iterable $pairs Associative list of key/value pairs. Both must be |
||
87 | * a string |
||
88 | * @param int|string|array $expires Associative list of keys and datetime |
||
89 | * string or integer TTL pairs. |
||
90 | * @param array $tags Associative list of key/tag or key/tags pairs that |
||
91 | * should be associated to the values identified by their key. The value |
||
92 | * associated to the key can either be a tag string or an array of tag strings |
||
93 | * @return null |
||
94 | * @throws \Aimeos\MW\Cache\Exception If the cache server doesn't respond |
||
95 | */ |
||
96 | public function setMultiple( $pairs, $expires = null, array $tags = array() ) |
||
148 | } |
||
149 |