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

## Source for file plain.php

Documentation is available at plain.php

1. <?php
2. /**
3. * File containing the ezcCacheStorageMemcachePlain 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. * This storage implementation stores data in a Memcache cache.
30. *
31. * @package Cache
32. * @version //autogentag//
33. */
34. class ezcCacheStorageMemcachePlain extends ezcCacheStorageMemcache
35. {
36. /**
37. * Fetches data from the cache.
38. *
39. * @param string $identifier The file to fetch data from
40. * @param bool $object Return the object and not the clean data
41. * @return mixed The fetched data or false on failure
42. */
43. protected function fetchData ( $identifier, $object = false )
44. {
45. // @TODO: This is also done in the backend, again. However, since the
46. // backend is public, too, we need to keep both for now.
47. $data = $this-> backend ->fetch( $identifier );
48. if ( is_object ( $data ) && $object === false )
49. {
50. return $data->data;
51. }
52. if ( is_object ( $data ) && $object !== false )
53. {
54. return $data;
55. }
56. else
57. {
58. return false;
59. }
60. }
62. /**
63. * Wraps the data in an ezcCacheStorageMemoryDataStruct structure in order
64. * to store it.
65. *
66. * @throws ezcCacheInvalidDataException
67. * If the data submitted can not be handled by this storage (resource).
68. *
69. * @param mixed $data Simple type or array
70. * @return ezcCacheStorageMemoryDataStruct Prepared data
71. */
72. protected function prepareData ( $data )
73. {
74. if ( is_resource ( $data ) )
75. {
76. throw new ezcCacheInvalidDataException ( gettype ( $data ), array( 'simple', 'array', 'object' ) );
77. }
78. return new ezcCacheStorageMemoryDataStruct ( $data, $this-> properties ['location'] );
79. }
80. }
81. ?>

Documentation generated by phpDocumentor 1.4.3