OverviewIntroductionThe Zend_Memory component is intended to manage data in an environment with limited memory. Memory objects (memory containers) are generated by memory manager by request and transparently swapped/loaded when it's necessary. For example, if creating or loading a managed object would cause the total memory usage to exceed the limit you specify, some managed objects are copied to cache storage outside of memory. In this way, the total memory used by managed objects does not exceed the limit you need to enforce. The memory manager uses Zend_Cache backends as storage providers. Example #1 Using Zend_Memory component Zend_Memory::factory() instantiates the memory manager object with specified backend options.
Theory of OperationZend_Memory component operates with the following concepts:
Memory managerThe memory manager generates memory objects (locked or movable) by request of user application and returns them wrapped into a memory container object. Memory containerThe memory container has a virtual or actual value attribute of string type. This attribute contains the data value specified at memory object creation time. You can operate with this value attribute as an object property:
Locked memoryLocked memory objects are always stored in memory. Data stored in locked memory are never swapped to the cache backend. Movable memoryMovable memory objects are transparently swapped and loaded to/from the cache backend by Zend_Memory when it's necessary. The memory manager doesn't swap objects with size less than the specified minimum, due to performance considerations. See this section for more details.
|