Introdução ao Zend Framework

 Conhecendo o Zend Framework

appendix

 Referência do Zend Framework


  • Zend_Gdata
  • Zend_Http
  • Zend_InfoCard
  • Zend_Json
  • Zend_Layout
  • Zend_Ldap
  • Zend_Loader
  • Zend_Locale
  • Zend_Log
  • Zend_Mail
  • Zend_Markup
  • Zend_Measure
  • Zend_Memory
  • Zend_Mime
  • Zend_Navigation
  • Zend_Oauth
  • Zend_OpenId
  • Zend_Paginator
  • Zend_Pdf
  • Zend_ProgressBar
  • Zend_Queue
  • Zend_Reflection
  • Zend_Registry
  • Zend_Rest

  • Zend_Search_Lucene
  • Zend_Serializer
  • Zend_Server
  • Zend_Service
  • Zend_Session
  • Zend_Soap
  • Zend_Tag
  • Zend_Test
  • Zend_Text
  • Zend_TimeSync
  • Zend_Tool
  • Zend_Tool_Framework
  • Zend_Tool_Project
  • Zend_Translate
  • Zend_Uri
  • Zend_Validate
  • Zend_Version
  • Zend_View
  • Zend_Wildfire
  • Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Translation 12.2% Update 2011-11-16 - Revision 24447 - Version ZF 1.11.x

    Capítulo 48. Zend_Memory

    48.1. Overview

    48.1.1. Introduction

    The 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.

    Exemplo 48.1. Using Zend_Memory component

    Zend_Memory::factory() instantiates the memory manager object with specified backend options.

    $backendOptions = array(
        
    'cache_dir' => './tmp/' // Directory where to put the swapped memory blocks
    );

    $memoryManager Zend_Memory::factory('File'$backendOptions);

    $loadedFiles = array();

    for (
    $count 0$count 10000$count++) {
        
    $f fopen($fileNames[$count], 'rb');
        
    $data fread($ffilesize($fileNames[$count]));
        
    $fclose($f);

        
    $loadedFiles[] = $memoryManager->create($data);
    }

    echo 
    $loadedFiles[$index1]->value;

    $loadedFiles[$index2]->value $newValue;

    $loadedFiles[$index3]->value[$charIndex] = '_';

    48.1.2. Theory of Operation

    Zend_Memory component operates with the following concepts:

    • Memory manager

    • Memory container

    • Locked memory object

    • Movable memory object

    48.1.2.1. Memory manager

    The memory manager generates memory objects (locked or movable) by request of user application and returns them wrapped into a memory container object.

    48.1.2.2. Memory container

    The 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:

    $memObject $memoryManager->create($data);

    echo 
    $memObject->value;

    $memObject->value $newValue;

    $memObject->value[$index] = '_';

    echo 
    ord($memObject->value[$index1]);

    $memObject->value substr($memObject->value$start$length);
    [Nota] Nota

    If you are using a PHP version earlier than 5.2, use the getRef() method instead of accessing the value property directly.

    48.1.2.3. Locked memory

    Locked memory objects are always stored in memory. Data stored in locked memory are never swapped to the cache backend.

    48.1.2.4. Movable memory

    Movable 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.

    digg delicious meneame google twitter technorati facebook

    Comments

    Loading...