定制 r0mdau/jisly 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

r0mdau/jisly

Composer 安装命令:

composer require r0mdau/jisly

包简介

The smallest NoSQL database library, flat file JSON.

README 文档

README

PHPUnit Coverage Status Known Vulnerabilities

The smallest PHP lightweight NoSQL database library, flat file JSON.

The main goal of Jisly is to allow you to quickly start your project with the possibility of memory and flat-file storage using a NoSQL (document oriented) query syntax.

Version française ici

Concurrent access is managed !

How to install and load

This lib can be found on Packagist

composer require r0mdau/jisly:^2.0

Loading the library

Jisly relies on the PSR-4 specification for autoloading classes from file paths.

use Jisly\JislyCollection;

public function saveCart(): void {
    $jisly = new JislyCollection("/tmp/data", "cart");
    ...
}

Definitions

  1. Each document has a unique identifier called _rid.
  2. Each collection is physically represented by a file.
  3. The files are stored in a single working directory. The Jisly class is instantiated with the path to this directory as a parameter.
  4. Each time you CRUD something, all datas are stored in memory.
  5. And datas are saved on filesystem.

Examples of use

Initialization of the class

$directory contains the path to the directory where the files (=collections) of the data model will be stored.

$database = new Jisly($directory);

To access a collection

$name contains the name of the collection we want to request. Example : user.

Returns an object JislyCollection :

$database->collection($name);

Warning : each first time you access a collection, all datas are stored in memory.

To call a collection

PREAMBLE : The Insert, Update, Delete methods return a boolean, true if the action went well, false otherwise.

Insert method

Insert the array into the specified collection in JSON format and assigns a unique _rid identifier to the document if it has not been specified :

$successBool = $database->collection($file)->insert(
  [
    "name" => "Lucas",
    "firstname" => "Georges"
  ]
);

Delete method

You must first find all documents to delete to provide the _rid attribute to the delete method.

Remove the only document in the collection which has the value $rid to the attribute _rid :

$successBool = $database->collection($file)->delete($rid);

Select method

Returns all documents in the collection in an array() of objects :

$results = $database->collection($file)->find();

Return all documents in the collection that have a name attribute with Lucas as value in an array() of objects :

$results = $database->collection($file)->find(
  [
    "name" => "Lucas"
  ]
);

Return the first document that as a name attribute with 19 as an object value :

$result = $database->collection($file)->findOne(
  [
    "name" => 19
  ]
);

Logical operators OR and AND

These two logical operators can be used on find and findOne methods.

If no logical operator is provided, OR is used.

Return all documents in the collection that have a name attribute with Lucas OR a firstname attribute with Georges as values in an array() of objects :

$result = $database->collection($file)->find(
  [
    "firstname" => "Georges",
    "name" => "Lucas"
  ], JislyCollection::LOGICAL_OR
);

Return the first document in the collection that have a name attribute with Lucas AND a firstname attribute with Georges as an object value :

$result = $database->collection($file)->findOne(
  [
    "firstname" => "Georges",
    "name" => "Lucas"
  ], JislyCollection::LOGICAL_AND
);

Update method

For the modification, the documents concerned are entirely replaced by the second array() given in parameter.

You must first find all the documents to replace to provide the _rid attribute to the update method.

Modify the only document in the collection whose value $rid to the _rid attribute :

$successBool = $database->collection($file)->update(
  $rid,
  [
    "firstname" => "Georges",
    "name" => "Lucas"
  ]
);

r0mdau/jisly 适用场景与选型建议

r0mdau/jisly 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62 次下载、GitHub Stars 达 26, 最近一次更新时间为 2016 年 11 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 r0mdau/jisly 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 r0mdau/jisly 我们能提供哪些服务?
定制开发 / 二次开发

基于 r0mdau/jisly 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 62
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 27
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 4
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2016-11-12