1: <?php
2: /**
3: * Adds a set of cached queries to the list handlers.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_Storage
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Kolab_Storage
12: */
13:
14: /**
15: * Adds a set of cached queries to the list handlers.
16: *
17: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you
20: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21: *
22: * @category Kolab
23: * @package Kolab_Storage
24: * @author Gunnar Wrobel <wrobel@pardus.de>
25: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
26: * @link http://pear.horde.org/index.php?package=Kolab_Storage
27: */
28: class Horde_Kolab_Storage_QuerySet_Cached
29: extends Horde_Kolab_Storage_QuerySet_Base
30: {
31: /**
32: * The query class map.
33: *
34: * @var array
35: */
36: protected $_class_map = array(
37: Horde_Kolab_Storage_List::QUERY_SHARE => 'Horde_Kolab_Storage_List_Query_Share_Cache',
38: Horde_Kolab_Storage_List::QUERY_BASE => 'Horde_Kolab_Storage_List_Query_List_Cache',
39: Horde_Kolab_Storage_List::QUERY_ACL => 'Horde_Kolab_Storage_List_Query_Acl_Cache',
40: Horde_Kolab_Storage_Data::QUERY_PREFS => 'Horde_Kolab_Storage_Data_Query_Preferences_Cache',
41: Horde_Kolab_Storage_Data::QUERY_HISTORY => 'Horde_Kolab_Storage_Data_Query_History_Cache',
42: );
43:
44: /**
45: * The cache.
46: *
47: * @var Horde_Kolab_Storage_Cache
48: */
49: private $_cache;
50:
51: /**
52: * Constructor.
53: *
54: * @param Horde_Kolab_Storage_Factory $factory The factory.
55: * @param array $params Optional parameters.
56: * @param Horde_Kolab_Storage_Cache $cache The cache.
57: */
58: public function __construct(Horde_Kolab_Storage_Factory $factory,
59: array $params = array(),
60: Horde_Kolab_Storage_Cache $cache = null)
61: {
62: parent::__construct($factory, $params);
63: $this->_cache = $cache;
64: }
65:
66: /**
67: * Fetch any additional parameters required when creating list queries.
68: *
69: * @param Horde_Kolab_Storage_List $list The list.
70: *
71: * @return array The parameters for list queries.
72: */
73: protected function _getListQueryParameters(Horde_Kolab_Storage_List $list)
74: {
75: return array(
76: 'cache' => $this->_cache->getListCache(
77: $list->getIdParameters()
78: )
79: );
80: }
81:
82: /**
83: * Fetch any additional parameters required when creating data queries.
84: *
85: * @param Horde_Kolab_Storage_Data $data The data.
86: *
87: * @return array The parameters for data queries.
88: */
89: protected function _getDataQueryParameters(Horde_Kolab_Storage_Data $data)
90: {
91: return array(
92: 'cache' => $this->_cache->getDataCache(
93: $data->getIdParameters()
94: )
95: );
96: }
97: }
98:
99: