Locked.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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-2008 Zend Technologies USA Inc. (http://www.zend.com)
  17. * @license http://framework.zend.com/license/new-bsd New BSD License
  18. */
  19. /** Zend_Memory_Container */
  20. require_once 'Zend/Memory/Container.php';
  21. /**
  22. * Memory value container
  23. *
  24. * Locked (always stored in memory).
  25. *
  26. * @category Zend
  27. * @package Zend_Memory
  28. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. */
  31. class Zend_Memory_Container_Locked extends Zend_Memory_Container
  32. {
  33. /**
  34. * Value object
  35. *
  36. * @var string
  37. */
  38. public $value;
  39. /**
  40. * Object constructor
  41. *
  42. * @param Zend_Memory_Manager $memoryManager
  43. * @param integer $id
  44. * @param string $value
  45. */
  46. public function __construct($value)
  47. {
  48. $this->value = $value;
  49. }
  50. /**
  51. * Lock object in memory.
  52. */
  53. public function lock()
  54. {
  55. /* Do nothing */
  56. }
  57. /**
  58. * Unlock object
  59. */
  60. public function unlock()
  61. {
  62. /* Do nothing */
  63. }
  64. /**
  65. * Return true if object is locked
  66. *
  67. * @return boolean
  68. */
  69. public function isLocked()
  70. {
  71. return true;
  72. }
  73. /**
  74. * Get string value reference
  75. *
  76. * _Must_ be used for value access before PHP v 5.2
  77. * or _may_ be used for performance considerations
  78. *
  79. * @return &string
  80. */
  81. public function &getRef()
  82. {
  83. return $this->value;
  84. }
  85. /**
  86. * Signal, that value is updated by external code.
  87. *
  88. * Should be used together with getRef()
  89. */
  90. public function touch()
  91. {
  92. /* Do nothing */
  93. }
  94. /**
  95. * Destroy memory container and remove it from memory manager list
  96. */
  97. public function destroy()
  98. {
  99. /* Do nothing */
  100. }
  101. }