Labels
Zend Framework: Zend_Memory Component Proposal
| Proposed Component Name | Zend_Memory |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Memory |
| Proposers | Alexander Veremyev |
| Revision | 1.0 - 21 July 2006: Created. (wiki revision: 15) |
Table of Contents
1. Overview
Zend_Memory is a component that offers API for managing data in limited memory mode.
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
- Module must effectively manage large amount of data.
- Memory management must be based on access statistics.
- Data load/unload process must be transparent for an application.
4. Dependencies on Other Framework Components
- Zend_Exception
5. Theory of Operation
User creates Zend_Memory objects to store binary (string) value by using appropriate backend (Zend_Cache backends).
Stored value can be accessed by 'value' property of Zend_Memory class.
6. Milestones / Tasks
- Milestone 1: Proposal is reviewed and approved by community
- Milestone 2: design notes will be published here
- Milestone 3: Working prototype checked into the incubator
- Milestone 4: Unit tests exist, work, and are checked into SVN.
- Milestone 5: Initial documentation exists.
- Milestone 6: Zend_Pdf is switched to use Zend_Memory for resources (take a look at ZF-12).
7. Class Index
- Zend_MemoryManager
- Zend_Memory
- Zend_Memory_Exception
8. Use Cases
| UC-01 |
|---|
| UC-02 |
|---|
| UC-03 |
|---|
9. Class Skeletons
If I'm understanding the manual section on Zend_Cache and the proposal for Zend_Memory correctly, Zend_Memory could theoretically be built on top of Zend_Cache. Where Zend_Cache backends are restricted to non-volatile storage, Zend_Memory would provide memory management which would rely on non-volatile backends only when necessary (utilizing Zend_Cache) and would swap data in and out of memory on the basis of request frequency.
The functionality is not the same.
Zend_Cache is intended to store data between script executions (requests), and Zend_Memory should store values during script execution (to free used memory while value is not used).
But Zend_Cache backends can (and should) be used as storage backends.
Thanks for your comment!
This proposal should also include functionality to leech the data from a file pointer (http stream etc) without consuming much memory to do it if its too large for the memory limit and I would be inclined to have Zend_Memory_Manager too that forked out Zend_Memory instances and monitored how much ram each Zend_Memory was using to keep a global ram limit in place for all of the containers.
Something to handle substr() of the dataset would also be useful to me.
I would also be inclined to use Zend_Cache in a way to have intelligently split the dataset into multiple smaller parts and use the cache on each of the pieces instead of the whole string.
This module would be VERY useful to me in quite a few projects where I could have anything upto 500meg of data loaded at once if it wasn't such a chore to do with php without overloading servers.
I do agree, that it's necessary to add Zend_Memory_Manager class.
I planned to use some static methods to request memory usage information, but memory manager conception is more common and clear.
File access management looks interesting. Do you mean something like "memory mapped files"? It may be future enhancement of Zend_Memory.
As to long strings management. I don't see now, how it may be implemented without complex API. I don't know way to hook access to the part of string.
invokes __get() method, which returns string or string reference. We don't know, which offset will be used.
ZF Home Page
Code Browser
Wiki Dashboard
Zend_Cache seems to have the same functionality as this proposal.
Where are the benefits from this proposal to the existing Zend_Cache ?
Greetings
Thomas