Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2025-02-19 (2 days ago)  | | Not yet rated by the users | | Total: Not yet counted | | Not yet ranked |
|
Description | | Author |
This package stores objects or arrays in a file and maintains their index start and end positions inside the file in the RAM.
The stored data is retrieved using these indexes of the respective keys hierarchy, separated by a colon, of the objects or arrays.
The package uses JSON to store a serialized version of the arrays or objects in the file. | |
 |
|
Innovation award
 Nominee: 5x
Winner: 4x |
|
Example
<?php
use HeavyObjects\Source\HeavyObject;
include_once('autoload.php');
$stream = fopen("php://temp", "rw+b");
$heavyObject = new HeavyObject($stream);
// Execute DB Query
$stmt = $db->select($sql);
// Load/Write/Update records to file
for ($i=0; $row = $stmt->fetch(PDO::FETCH_ASSOC); $i++) {
$heavyObject->write($row, $keys = "row:{$i}");
}
// Get/Read records from file
$key = 10;
$row = $heavyObject->read("row:{$key}");
echo '<pre>';
echo 'row:'; print_r($row);
echo 'Count:' . $heavyObject->count('row');
|
Details
Heavy-Objects
Manage Heavy(RAM intensive) Array/Object Collections via single File in filesystem using limited RAM.
Examples
Memory usage by 1000 raw objects each with 100 keys (~12 MB)
<?php
$rows = [];
for ($i=0; $i<1000; $i++) {
$row = [];
for($j=0;$j<100;$j++) {
$row["Key{$j}"] = rand();
}
$rows[] = $row;
}
echo '<pre>';
echo memory_get_usage(); // 11,842,144 bytes
Memory usage by 1000 HeavyObjects each with 100 keys (~2.5 MB)
<?php
use HeavyObjects\Source\HeavyObject;
include_once('autoload.php');
$stream = fopen("php://temp", "rw+b");
$heavyObject = new HeavyObject($stream);
// Load/Write/Update records to file
for ($i=0; $i<1000; $i++) {
$row = [];
for($j=0;$j<100;$j++) {
$row["Key{$j}"] = rand();
}
$heavyObject->write($row, $keys = "row:{$i}");
}
echo '<pre>';
echo memory_get_usage(); // 2,659,224 bytes
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.