## Apache Zeta Components Manual :: File Source for storage_memcache.php

## Source for file storage_memcache.php

Documentation is available at storage_memcache.php

1. <?php
2. /**
3. * File containing the ezcCacheStorageMemcacheOptions class.
4. *
5. * Licensed to the Apache Software Foundation (ASF) under one
6. * or more contributor license agreements. See the NOTICE file
7. * distributed with this work for additional information
8. * regarding copyright ownership. The ASF licenses this file
9. * to you under the Apache License, Version 2.0 (the
10. * "License"); you may not use this file except in compliance
11. * with the License. You may obtain a copy of the License at
12. *
13. * http://www.apache.org/licenses/LICENSE-2.0
14. *
15. * Unless required by applicable law or agreed to in writing,
16. * software distributed under the License is distributed on an
17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18. * KIND, either express or implied. See the License for the
19. * specific language governing permissions and limitations
20. * under the License.
21. *
22. * @package Cache
23. * @version //autogentag//
24. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
25. * @filesource
26. */
28. /**
29. * Option class for defining a connection to a Memcache server.
30. *
31. * @property string $host
32. * The name of the Memcache host to use, usually localhost.
33. * @property int $port
34. * The port on which to connect to host, usually 11211.
35. * @property bool $persistent
36. * If a persistent connection to the Memcache host is needed. Default
37. * is false. A persistent connection stays open between requests.
38. * @property bool $compressed
39. * If on-the-fly compression is needed. Default is false. Requires the
40. * zlib PHP extension.
41. * @property string $lockKey
42. * Cache key to use for locking. Default is '.ezcLock'.
43. * @property int $lockWaitTime
44. * Time to wait between lock availability checks. Measured in
45. * microseconds ({@link usleep()}). Default is 200000.
46. * @property int $maxLockTime
47. * Time before a lock is considered dead, measured in seconds.
48. * Default is 5.
49. * @property string $metaDataKey
50. * The name of the file used to store meta data. Default is
51. * '.ezcMetaData'.
52. *
53. * @package Cache
54. * @version //autogentag//
55. */
56. class ezcCacheStorageMemcacheOptions extends ezcBaseOptions
57. {
58. /**
59. * Parent storage options.
60. *
61. * @var ezcCacheStorageOptions
62. */
63. protected $storageOptions ;
65. /**
66. * Constructs an object with the specified values.
67. *
68. * @throws ezcBasePropertyNotFoundException
69. * If $options contains a property not defined.
70. * @throws ezcBaseValueException
71. * If $options contains a property with a value not allowed.
72. * @param array(string=>mixed) $options
73. */
74. public function __construct ( array $options = array() )
75. {
76. $this-> properties ['host'] = 'localhost';
77. $this-> properties ['port'] = 11211;
78. $this-> properties ['persistent'] = false;
79. $this-> properties ['compressed'] = false;
80. $this-> properties ['lockWaitTime'] = 200000;
81. $this-> properties ['maxLockTime'] = 5;
82. $this-> properties ['lockKey'] = '.ezcLock';
83. $this-> properties ['metaDataKey'] = '.ezcMetaData';
84. $this-> storageOptions = new ezcCacheStorageOptions ();
86. parent:: __construct ( $options );
87. }
89. /**
90. * Sets the option $name to $value.
91. *
92. * @throws ezcBasePropertyNotFoundException
93. * If the property $name is not defined.
94. * @throws ezcBaseValueException
95. * If $value is not correct for the property $name.
96. * @param string $name
97. * @param mixed $value
98. * @ignore
99. */
100. public function __set( $name, $value )
101. {
102. switch ( $name )
103. {
104. case 'host':
105. if ( ! is_string ( $value ) || strlen ( $value ) < 1 )
106. {
107. throw new ezcBaseValueException ( $name, $value, 'string, length > 0' );
108. }
109. break;
110. case 'port':
111. if ( ! is_int ( $value ) || $value < 1 )
112. {
113. throw new ezcBaseValueException ( $name, $value, 'int > 0' );
114. }
115. break;
116. case 'persistent':
117. case 'compressed':
118. if ( ! is_bool ( $value ) )
119. {
120. throw new ezcBaseValueException ( $name, $value, 'bool' );
121. }
122. break;
123. case 'lockWaitTime':
124. case 'maxLockTime':
125. if ( ! is_int ( $value ) || $value < 1 )
126. {
127. throw new ezcBaseValueException ( $name, $value, 'int > 0' );
128. }
129. break;
130. case 'lockKey':
131. case 'metaDataKey':
132. if ( ! is_string ( $value ) || strlen ( $value ) < 1 )
133. {
134. throw new ezcBaseValueException ( $name, $value, 'string, length > 0' );
135. }
136. break;
137. default:
138. // Delegate
139. $this-> storageOptions ->$name = $value;
140. }
141. $this-> properties [$name] = $value;
142. }
144. /**
145. * Returns the value of the option $name.
146. *
147. * @throws ezcBasePropertyNotFoundException
148. * If the property $name is not defined.
149. * @param string $name The name of the option to get.
150. * @return mixed The option value.
151. * @ignore
152. */
153. public function __get( $name )
154. {
155. if ( isset( $this-> properties [$name] ) )
156. {
157. return $this-> properties [$name];
158. }
160. // Delegate
161. return $this-> storageOptions ->$name;
162. }
164. /**
165. * Returns if option $name is defined.
166. *
167. * @param string $name Option name to check for
168. * @return bool
169. * @ignore
170. */
171. public function __isset( $name )
172. {
173. return ( isset( $this-> properties [$name] ) || isset( $this-> storageOptions ->$name ) );
174. }
176. /**
177. * Merge an ezcCacheStorageOptions object into this object.
178. *
179. * @param ezcCacheStorageOptions $options The options to merge.
180. * @return void
181. * @ignore
182. */
183. public function mergeStorageOptions( ezcCacheStorageOptions $options )
184. {
185. $this-> storageOptions = $options;
186. }
187. }
188. ?>

Documentation generated by phpDocumentor 1.4.3