fire015/flintstone
Composer 安装命令:
composer require fire015/flintstone
包简介
A key/value database store using flat files for PHP
README 文档
README
A key/value database store using flat files for PHP.
Features include:
- Memory efficient
- File locking
- Caching
- Gzip compression
- Easy to use
Installation
The easiest way to install Flintstone is via composer. Run the following command to install it.
composer require fire015/flintstone
<?php require 'vendor/autoload.php'; use Flintstone\Flintstone; $users = new Flintstone('users', ['dir' => '/path/to/database/dir/']);
Requirements
- PHP 7.3+
Data types
Flintstone can store any data type that can be formatted into a string. By default this uses serialize(). See Changing the formatter for more details.
Options
| Name | Type | Default Value | Description |
|---|---|---|---|
| dir | string | the current working directory | The directory where the database files are stored (this should be somewhere that is not web accessible) e.g. /path/to/database/ |
| ext | string | .dat | The database file extension to use |
| gzip | boolean | false | Use gzip to compress the database |
| cache | boolean or object | true | Whether to cache get() results for faster data retrieval |
| formatter | null or object | null | The formatter class used to encode/decode data |
| swap_memory_limit | integer | 2097152 | The amount of memory to use before writing to a temporary file |
Usage examples
<?php // Load a database $users = new Flintstone('users', ['dir' => '/path/to/database/dir/']); // Set a key $users->set('bob', ['email' => 'bob@site.com', 'password' => '123456']); // Get a key $user = $users->get('bob'); echo 'Bob, your email is ' . $user['email']; // Retrieve all key names $keys = $users->getKeys(); // returns array('bob') // Retrieve all data $data = $users->getAll(); // returns array('bob' => array('email' => 'bob@site.com', 'password' => '123456')); // Delete a key $users->delete('bob'); // Flush the database $users->flush();
Changing the formatter
By default Flintstone will encode/decode data using PHP's serialize functions, however you can override this with your own class if you prefer.
Just make sure it implements Flintstone\Formatter\FormatterInterface and then you can provide it as the formatter option.
If you wish to use JSON as the formatter, Flintstone already ships with this as per the example below:
<?php require 'vendor/autoload.php'; use Flintstone\Flintstone; use Flintstone\Formatter\JsonFormatter; $users = new Flintstone('users', [ 'dir' => __DIR__, 'formatter' => new JsonFormatter() ]);
Changing the cache
To speed up data retrieval Flintstone can store the results of get() in a cache store. By default this uses a simple array that only persist's for as long as the Flintstone object exists.
If you want to use your own cache store (such as Memcached) you can pass a class as the cache option. Just make sure it implements Flintstone\Cache\CacheInterface.
fire015/flintstone 适用场景与选型建议
fire015/flintstone 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 111.48k 次下载、GitHub Stars 达 284, 最近一次更新时间为 2014 年 03 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「cache」 「memory」 「files」 「flintstone」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fire015/flintstone 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fire015/flintstone 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fire015/flintstone 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
repository php library
Store your language lines in the database, yaml or other sources
PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
统计信息
- 总下载量: 111.48k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 284
- 点击次数: 15
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-03-11