PHPackages                             simpletools/db-indexedfile - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. simpletools/db-indexedfile

ActiveLibrary[Framework](/categories/framework)

simpletools/db-indexedfile
==========================

High-throughput non-concurrent NoSQL key-value file-based database with a memory-backed index.

1.0.11(1y ago)03.7k↓33.3%BSD-3-ClausePHPPHP &gt;=7.0.0

Since Aug 8Pushed 1y ago2 watchersCompare

[ Source](https://github.com/getsimpletools/db-indexedfile)[ Packagist](https://packagist.org/packages/simpletools/db-indexedfile)[ Docs](http://www.getsimpletools.com/)[ RSS](/packages/simpletools-db-indexedfile/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (12)Used By (0)

High-throughput non-concurrent NoSQL key-value file-based database with a memory-backed index.
==============================================================================================

[](#high-throughput-non-concurrent-nosql-key-value-file-based-database-with-a-memory-backed-index)

IndexedFile is a DB system allowing to very quickly process and store big amount of data by leveraging memory as an index while keeping all the other data on disk with high-throughput read and write engine.

To simplify snippets below, its assumed that the following namespaces are in `use`:

```
use \Simpletools\Db\IndexedFile;
```

### Initialise Temp DB

[](#initialise-temp-db)

To start a new temp DB which will get removed when the script terminates:

```
$indexedFile = new IndexedFile\File();
```

### Initialise from existing DB

[](#initialise-from-existing-db)

To start DB which might have already exists or which should persist after script terminate:

```
$indexedFile = new IndexedFile\File('/path/to/my/db.jsonl');
```

### Setup a custom IndexStore

[](#setup-a-custom-indexstore)

You can write your own IndexStore which implements `IndexStoreInterface` and preset it with the following static method:

```
//the default IndexStore
IndexedFile\File::indexStoreClass('Simpletools\Db\IndexedFile\IndexStore\ArrayIndexStore');
```

### Storing data

[](#storing-data)

Inserting/Replacing data by key

```
$indexedFile->insert('key',["foo"=>"bar"]);
```

### Storing data if not exists

[](#storing-data-if-not-exists)

Ignoring insert if key already exists

```
$indexedFile->insertIgnore('key',["foo"=>"bar"]);
```

### Reading data

[](#reading-data)

Reading by key

```
$value = $indexedFile->read('key');
```

### Iterating through all entries

[](#iterating-through-all-entries)

Iterating through all entires

```
foreach($indexedFile->iterate() as $key => $value)
{
    var_dump($key,$value);
}
```

### Upserting data

[](#upserting-data)

Updating/Inserting your data

```
$indexedFile->upsert('key',function($row){
    if($row)
    {
        $row->counter++;
        return $row;
    }
    else
    {
        return [
            'counter'   => 0
        ];
    }
});
```

### Removing data

[](#removing-data)

Removing a key

```
$indexedFile->remove('key');
```

### Truncating database

[](#truncating-database)

Removing all entires

```
$indexedFile->truncate();
```

or when booting up

```
$indexedFile = new IndexedFile\File('/path/to/my/db.jsonl',true);
```

### Sorting

[](#sorting)

Declare text sort

```
$indexedFile->sort('title','ASC', 'string');
```

Declare integer sort

```
$indexedFile->sort('count','DESC', 'int');
```

`includeSortStats` flag adds to the indexed object `_sort` meta field with `position` in sort and `percent` of total (integer only)

```
$indexedFile->sort('count','DESC', 'int', true);
```

Own input and output files

```
$indexedFile->sort('title','ASC', 'string',true, __DIR__.'/unsorted.csv', __DIR__.'/sorted.csv');
```

Example of use for sorting by price and list with an iterator

```
$indexedFile->sort('price','DESC', 'int');

$indexedFile->insertIgnore($data['id'],[
    'title' => $data['title'],
    'price' => $data['price']
]);

$indexedFile->runSort();

foreach ($indexedFile->sortIterate() as $groupId => $row)
{
  echo 'Position: '. $row->_sort->position.' Percent: '.$row->_sort->position.' Index key: '. $groupId .' Price: '. $row->price."\n";
}
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance43

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~129 days

Recently: every ~290 days

Total

11

Last Release

448d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b68f518668b98cc8d9937613ee8075bed70ead2a42ab8c44ef2842df008b9c9?d=identicon)[marcinrosinski](/maintainers/marcinrosinski)

---

Top Contributors

[![marcinrosinski](https://avatars.githubusercontent.com/u/195465?v=4)](https://github.com/marcinrosinski "marcinrosinski (6 commits)")

---

Tags

framework

### Embed Badge

![Health badge](/badges/simpletools-db-indexedfile/health.svg)

```
[![Health](https://phpackages.com/badges/simpletools-db-indexedfile/health.svg)](https://phpackages.com/packages/simpletools-db-indexedfile)
```

###  Alternatives

[hemp/presenter

Easy Model Presenters in Laravel

247592.6k1](/packages/hemp-presenter)[pestphp/pest-plugin-stressless

Stressless plugin for Pest

67792.6k16](/packages/pestphp-pest-plugin-stressless)[wpstarter/framework

The WpStarter Framework - Laravel Framework for WordPress

1810.1k4](/packages/wpstarter-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
