承接 globalis/wp-cubi-transient-cache 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

globalis/wp-cubi-transient-cache

Composer 安装命令:

composer require globalis/wp-cubi-transient-cache

包简介

README 文档

README

PHP Version Require Latest Stable Version License

Persistent cache library based on WordPress transients

wp-cubi

Features

  • Provides Cache::set() and Cache::get() methods, using transients
  • Provides Template::get() method, that automatically caches required template part
  • Automatically cache WordPress nav-menus out of the box
  • Clear cache by group, when menus are saved, when posts are saved, when site URL changes

Installation

composer require globalis/wp-cubi-transient-cache

Usage

Generic caching

Save a value in cache :

<?php

use Globalis\WP\Cubi\TransientCache\Cache;

$my_value = my_expensive_function();
Cache::set('my_key', $my_value, 'my_group');

Get a value from cache :

<?php

use Globalis\WP\Cubi\TransientCache\Cache;

$my_value_cached = Cache::get('my_key', 'my_group');

Clear a single cache entry :

<?php

use Globalis\WP\Cubi\TransientCache\Cache;

Cache::clear('my_key', 'my_group');

Clear multiple cache entries :

<?php

use Globalis\WP\Cubi\TransientCache\Cache;

Cache::clearGroups(['my_group']);

Templates caching

Get a template part from cache :

<?php

use Globalis\WP\Cubi\TransientCache\Template;

Template::get('templates/my-part', ['my_arg' => 'example'], 'my_group');

When a template part cache value doesn't exists, Template::get() will automatically loads required template part, and cache it, so you just have to replace calls to WordPress core function get_template_part() with Template::get() to enable cache on a template part.

Templates cache uses generic clear methods, using file path as key (e.g. Cache::clear('templates/my-part', 'my_group');).

Nav-menus caching

Nav-menus are automatically cached and several hooks are setup out of the box to clear their cache when needed.

You can always manually clear all menus cache with :

<?php

use Globalis\WP\Cubi\TransientCache\Cache;

Cache::clearGroups(['menus']);

Procedural style

Most of the above methods can be called in a procedural style, without any namespace :

<?php

wp_cubi_cache_set(string $key, mixed $value, string $group = 'all');
wp_cubi_cache_get(string $key, string $group = 'all');
wp_cubi_cache_clear(string $key, string $group = 'all');
wp_cubi_cache_clear_group(string $group = 'all');
wp_cubi_cache_clear_groups(array $groups = ['all']);
wp_cubi_get_template_part_cached(string $file, array $data = [], string $group = 'all', bool $return = false);

Configuration

Bypass cache when developping, or in a specific environment config file :

<?php

define('WP_CUBI_TRANSIENT_CACHE_BYPASS_ALL', true);

Bypass cache only for template parts :

<?php

define('WP_CUBI_TRANSIENT_CACHE_BYPASS_TEMPLATES', true);

Disable nav-menus automatic caching :

<?php

define('WP_CUBI_TRANSIENT_CACHE_DISABLE_AUTO_CACHE_NAV_MENUS', true);

Hooks

Clear all cache :

do_action('wp-cubi\transient-cache\clear');

Filter clear hooks :

apply_filters('wp-cubi\transient-cache\clear-hooks', $hooks);

Development

Before opening pull requests, please check and apply project coding standards with ./vendor/bin/phpcs . and/or ./vendor/bin/phpcbf .

globalis/wp-cubi-transient-cache 适用场景与选型建议

globalis/wp-cubi-transient-cache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.4k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 globalis/wp-cubi-transient-cache 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2023-03-21