Source for file Storage.class.php

Documentation is available at Storage.class.php

  1. <?php
  2. /**
  3. * XOAD_Cache Storage File.
  4. *
  5. * <p>This file defines the {@link XOAD_Cache_Storage} Class.</p>
  6. * <p>You should not include this file directly. It is used
  7. * by {@link XOAD_Cache} extension.</p>
  8. *
  9. * @author Stanimir Angeloff
  10. *
  11. * @package XOAD
  12. *
  13. * @subpackage XOAD_Cache
  14. *
  15. * @version 0.6.0.0
  16. *
  17. */
  18.  
  19. /**
  20. * XOAD_Cache Storage Class.
  21. *
  22. * <p>This class is used as base class for all XOAD_Cache
  23. * storage providers.</p>
  24. * <p>Example XOAD_Cache provider: {@link XOAD_Cache_Storage_Files}.</p>
  25. *
  26. * @author Stanimir Angeloff
  27. *
  28. * @package XOAD
  29. *
  30. * @subpackage XOAD_Cache
  31. *
  32. * @version 0.6.0.0
  33. *
  34. */
  35. class XOAD_Cache_Storage
  36. {
  37. /**
  38. * Creates a new instance of the {@link XOAD_Cache_Storage} class.
  39. *
  40. * @access public
  41. *
  42. * @param string $dsn The data source name and parameters to use
  43. * when creating the instance.
  44. *
  45. */
  46. function XOAD_Cache_Storage($dsn = null)
  47. {
  48. if ( ! empty($dsn)) {
  49.  
  50. $pairs = explode(';', $dsn);
  51.  
  52. foreach ($pairs as $pair) {
  53.  
  54. if ( ! empty($pair)) {
  55.  
  56. list($key, $value) = explode('=', $pair, 2);
  57.  
  58. $this->$key = $value;
  59. }
  60. }
  61. }
  62. }
  63.  
  64. /**
  65. * Generates an unique ID from the given data.
  66. *
  67. * @access public
  68. *
  69. * @param string $data The data to use when generating the ID.
  70. *
  71. * @return string The unique ID from the given data.
  72. *
  73. */
  74. function generateID($data = null)
  75. {
  76. return md5($data);
  77. }
  78.  
  79. /**
  80. * Abstract base class method.
  81. *
  82. * <p>Successor classes should override this method.</p>
  83. *
  84. * @access public
  85. *
  86. * @return bool
  87. *
  88. */
  89. function collectGarbage()
  90. {
  91. return true;
  92. }
  93.  
  94. /**
  95. * Abstract base class method.
  96. *
  97. * <p>Successor classes should override this method.</p>
  98. *
  99. * @param mixed $id The ID of the cached data.
  100. *
  101. * @access public
  102. *
  103. * @return mixed
  104. *
  105. */
  106. function load($id = null)
  107. {
  108. return null;
  109. }
  110.  
  111. /**
  112. * Abstract base class method.
  113. *
  114. * <p>Successor classes should override this method.</p>
  115. *
  116. * @access public
  117. *
  118. * @param mixed $id The ID to use when saving the data.
  119. *
  120. * @param int $expires The lifetime time in seconds for the
  121. * cached data.
  122. *
  123. * @param mixed $data The data to cache.
  124. *
  125. * @return bool
  126. *
  127. */
  128. function save($id = null, $expires = null, $data = null)
  129. {
  130. return true;
  131. }
  132. }
  133. ?>

Documentation generated on Sat, 12 Nov 2005 20:24:49 +0200 by phpDocumentor 1.3.0RC3