alex-kalanis/kw_storage 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

alex-kalanis/kw_storage

Composer 安装命令:

composer require alex-kalanis/kw_storage

包简介

Universal storage library for store data as key-value pairs

README 文档

README

Build Status Scrutinizer Code Quality Latest Stable Version Minimum PHP Version Downloads License Code Coverage

Simple system for accessing key-value storages. Original is part of UploadPerPartes, where it's necessary for store states of upload. To data it behaves like simple key-value storage. Which can derive to real flat storages like memory or redis or tree-like structures like your normal filesystem. No streams here.

The main thing about this package are the interfaces. Especially IStorage which represents all supported operations over storages and shall be used on upper layers as the only necessary dependency.

It is also the correct way to get it via Access\Factory class which select the best possible storage in accordance with passed params from your configuration. That can be put inside your DI.

This package also contains translations interface. So you can customize error messages for your devs and users.

PHP Installation

composer.phar require alex-kalanis/kw_storage

(Refer to Composer Documentation if you are not familiar with composer)

Changes

  • 6.0 - Use DateTime interfaces, tests for 8.4 and own namespaces
  • 5.0 - Streams are on different level, not here
  • 4.0 - Redefine factories and some key classes
  • 3.0 - Redefine interfaces for targets
  • 2.0 - Redefine Key-Value storing data
    • Remove formats and cache support (that should not be a problem of storage)
    • Added stream variant support
    • Added interface for catching content with sub-content (so directories) on storage-level
  • 1.0 - Initial version, with basics and cache support

PHP Usage

It partially depends on real storage. Can be local filesystem, can be remote service too. But the interfaces in this package make them all equal in terms of usage. So...

1.) Use your autoloader (if not already done via Composer autoloader)

2.) Add some external packages with connection to the local or remote services. Can be Redis or AWS or something else. Or nothing if it is only local FS.

3.) Connect either kalanis\kw_storage\Interfaces\IStorage, kalanis\kw_storage\Storage or kalanis\kw_storage\Helper into your app. That usually happens in DI. Extend it for setting your case, especially if you use tree with dirs.

4.) Extend your libraries by interfaces inside the package. Mainly kalanis\kw_storage\Interfaces\IStorage which represents that available actions or kalanis\kw_storage\Storage which packs it like facade.

5.) Just use inside your app.

// DI-like
return function (array $params): \kalanis\kw_storage\Interfaces\IStorage {
    $storage = (new \kalanis\kw_storage\Storage(
        new \kalanis\kw_storage\Storage\Factory()) // here can be changed to select different storage
    );
    $storage->init($params);
    return $storage->getStorage();
}
// Classes
class Counter
{
    protected const string MY_KEY = 'my_key';

    public function __construct(
        // ...
        protected readonly \kalanis\kw_storage\Interfaces\IStorage $storage,
        // ...
    ) {
    }

    public function __destruct()
    {
        $this->storage->remove(static::MY_KEY);
    }

    public function clear(): bool
    {
        return $this->storage->write(static::MY_KEY, '0');
    }

    public function increment(): bool
    {
        return $this->storage->increment(static::MY_KEY);
    }

    public function get(): int
    {
        try {
            return intval($this->storage->read(static::MY_KEY));
        } catch (\kalanis\kw_storage\StorageException $ex) {
            return 0;
        }
    }
}

Notes

Listing output contains storage separators. Asked root record is empty, the rest has that separator at least on the beginning. It depends on storage and class if the listing came with complete tree with sub-entries or just first level.

alex-kalanis/kw_storage 适用场景与选型建议

alex-kalanis/kw_storage 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.96k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 12 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cache」 「storage」 「volume」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 alex-kalanis/kw_storage 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 4.96k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 20
  • 推荐数: 13

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2020-12-22