Locked.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @package Zend_Memory
  16. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  17. * @license http://framework.zend.com/license/new-bsd New BSD License
  18. * @version $Id$
  19. */
  20. /** Zend_Memory_Container */
  21. require_once 'Zend/Memory/Container.php';
  22. /**
  23. * Memory value container
  24. *
  25. * Locked (always stored in memory).
  26. *
  27. * @category Zend
  28. * @package Zend_Memory
  29. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_Memory_Container_Locked extends Zend_Memory_Container
  33. {
  34. /**
  35. * Value object
  36. *
  37. * @var string
  38. */
  39. public $value;
  40. /**
  41. * Object constructor
  42. *
  43. * @param Zend_Memory_Manager $memoryManager
  44. * @param integer $id
  45. * @param string $value
  46. */
  47. public function __construct($value)
  48. {
  49. $this->value = $value;
  50. }
  51. /**
  52. * Lock object in memory.
  53. */
  54. public function lock()
  55. {
  56. /* Do nothing */
  57. }
  58. /**
  59. * Unlock object
  60. */
  61. public function unlock()
  62. {
  63. /* Do nothing */
  64. }
  65. /**
  66. * Return true if object is locked
  67. *
  68. * @return boolean
  69. */
  70. public function isLocked()
  71. {
  72. return true;
  73. }
  74. /**
  75. * Get string value reference
  76. *
  77. * _Must_ be used for value access before PHP v 5.2
  78. * or _may_ be used for performance considerations
  79. *
  80. * @return &string
  81. */
  82. public function &getRef()
  83. {
  84. return $this->value;
  85. }
  86. /**
  87. * Signal, that value is updated by external code.
  88. *
  89. * Should be used together with getRef()
  90. */
  91. public function touch()
  92. {
  93. /* Do nothing */
  94. }
  95. /**
  96. * Destroy memory container and remove it from memory manager list
  97. */
  98. public function destroy()
  99. {
  100. /* Do nothing */
  101. }
  102. }