Zend Framework の紹介

 Learning Zend Framework

appendix

 Zend Framework リファレンス


  • 第36章 Zend_Gdata
  • 第37章 Zend_Http
  • 第38章 Zend_InfoCard
  • 第39章 Zend_Json
  • 第40章 Zend_Layout
  • 第41章 Zend_Ldap
  • 第42章 Zend_Loader
  • 第43章 Zend_Locale
  • 第44章 Zend_Log
  • 第45章 Zend_Mail
  • 第46章 Zend_Markup
  • 第47章 Zend_Measure
  • 第48章 Zend_Memory
  • 第49章 Zend_Mime
  • 第50章 Zend_Navigation
  • 第51章 Zend_Oauth
  • 第52章 Zend_OpenId
  • 第53章 Zend_Paginator
  • 第54章 Zend_Pdf
  • 第55章 Zend_ProgressBar
  • 第56章 Zend_Queue
  • 第57章 Zend_Reflection
  • 第58章 Zend_Registry
  • 第59章 Zend_Rest

  • 第60章 Zend_Search_Lucene
  • 第61章 Zend_Serializer
  • 第62章 Zend_Server
  • 第63章 Zend_Service
  • 第64章 Zend_Session
  • 第65章 Zend_Soap
  • 第66章 Zend_Tag
  • 第67章 Zend_Test
  • 第68章 Zend_Text
  • 第69章 Zend_TimeSync
  • 第70章 Zend_Tool
  • 第71章 Zend_Tool_Framework
  • 第72章 Zend_Tool_Project
  • 第73章 Zend_Translate
  • 第74章 Zend_Uri
  • 第75章 Zend_Validate
  • 第76章 Zend_Version
  • 第77章 Zend_View
  • 第78章 Zend_Wildfire
  • 第79章 Zend_XmlRpc
  • ZendX_Console_Process_Unix
  • ZendX_JQuery
  • Translation 70.6% Update 2010-11-28 - Revision 23415

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

    例 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);
    [注意] 注意

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