alex-kalanis/kw_storage
Composer 安装命令:
composer require alex-kalanis/kw_storage
包简介
Universal storage library for store data as key-value pairs
README 文档
README
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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alex-kalanis/kw_storage 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
repository php library
Small library to access Microsoft Windows Azure Blob Storage with a Service or a StreamWrapper.
A PHP wrapper for using DataForSEO API
Volume and dimensional calculation utilities for PHP 8.4+
Laravel 5 - Repositories to the database layer
统计信息
- 总下载量: 4.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 20
- 推荐数: 13
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2020-12-22