alleyinteractive/wp-big-pit 问题修复 & 功能扩展

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

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

alleyinteractive/wp-big-pit

Composer 安装命令:

composer require alleyinteractive/wp-big-pit

包简介

The WordPress database table for everything else.

README 文档

README

The Big Pit is a key-value WordPress database table for storing things that don't make sense to store as a post, term, option, or other core data type.

Installation

You can install the package via Composer:

composer require alleyinteractive/wp-big-pit

API

The Alley\WP\Big_Pit\Client interface describes the create-read-update-delete operations that can be used with the Big Pit. You can type hint against this interface when using Big Pit as a dependency.

namespace Alley\WP\Big_Pit;

use Alley\WP\Types\Feature;

interface Client extends Feature {
	public function value( string $key, string $group ): mixed;

	public function set( string $key, mixed $value, string $group ): void;

	public function delete( string $key, string $group ): void;

	public function group( string $key ): iterable;

	public function flush_group( string $group ): void;
}

Each item in the Big Pit has a key and a group, much like the WordPress object cache. Each key is unique within a group.

Client extends the Alley\WP\Types\Feature interface from the Type Extensions library, which includes a boot() method for performing side effects.

You must call boot() before using the client. If you are compiling features using the Features instance from Type Extensions, you can include the Big Pit client, and it will be booted with the rest of your feature classes.

Usage

<?php

use Alley\WP\Big_Pit;

$external_id  = 'abcdef12345';
$api_response = '{"id":"abcdef12345","title":"The Best Movie Ever","rating":5}';

$big_pit = new Big_Pit\Big_Pit();
$big_pit->boot();

$big_pit->set( $external_id, $api_response, 'movie_reviews' );
$big_pit->value( $external_id, 'movie_reviews' ); // '{"id":"abcdef12345","title":"The Best Movie Ever","rating":5}'
$big_pit->delete( $external_id, 'movie_reviews' );
$big_pit->flush_group( 'movie_reviews' );

Speculative Client

The Big_Speculative_Pit decorator class tracks the items that are fetched during a given request and preloads those items in a single query the next time the same page is requested.

<?php

use Alley\WP\Big_Pit;

$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();

$big_pit = new Big_Pit\Big_Speculative_Pit(
  request: $request,
  origin: new Big_Pit\Big_Pit(),
);

PSR-16 Cache Adapter

A PSR-16 adapter is available for caching data in The Pit:

<?php

// Each instance of the cache adapter is bound to a group. Create different instances to save to different groups.
$cache = \Alley\WP\SimpleCache\Big_Pit_Adapter::create( group: 'movie_reviews' );

$cache->get( /* ... */ );
$cache->set( /* ... */ );
$cache->delete( /* ... */ );
$cache->clear();
// etc.

Note that the cache adapter will store data in a custom array structure, as described in the wp-psr16 README.

Why Not Use Options?

There's nothing wrong with using options for storing key-value data, but it comes with overhead, including:

  • Managing autoloading and the alloptions cache.
  • pre_option_ and option_ filters on the values.
  • Settings registration and default values.

Big Pit doesn't have autoloading, filters, or registered keys, so it might work for you if you don't need these features.

Or, you might plan to store thousands of rows, and you don't want to dilute the options table with that amount of data.

About

License

GPL-2.0-or-later

Maintainers

Alley Interactive

alleyinteractive/wp-big-pit 适用场景与选型建议

alleyinteractive/wp-big-pit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.17k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 10 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 alleyinteractive/wp-big-pit 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 9.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 18
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2024-10-18