承接 alejoasotelo/joomla-cache-compat 相关项目开发

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

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

alejoasotelo/joomla-cache-compat

Composer 安装命令:

composer require alejoasotelo/joomla-cache-compat

包简介

Joomla Cache Package - PSR Compatbility

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

This cache package is based on a version of the now accepted PSR-6 as it was in 2013.

Deprecated

The alejoasotelo/joomla-cache-compat package has been deprecated with no further updates planned.

Options and General Usage

Following option as available across a cache storage types:

  • ttl - Time to live.
use Joomla\Cache;

$options = array(
	'ttl' => 900,
);

$cache = new Cache\Runtime($options);

// Set a value in the cache.
$cache->set('key', 'value');

// Get the value back.
$value = $cache->get('key')->getValue();

// Remove the item from the cache.
$cache->remove('key');

// Clear all the items from the cache.
$cache->clear();

// Get multiple values from the cache at once.
$values = $cache->getMultiple(array('key1', 'key2'));

// Set multiple values from the cache at once.
$values = $cache->setMultiple(array('key1' => 'value1', 'key2' => 'value2'));

// Remove multiple values from the cache at once.
$values = $cache->removeMultiple(array('key1', 'key2'));

Cache Storage Types

The following storage types are supported.

Apc

use Joomla\Cache;

$cache = new Cache\Apc;

File

The File cache allows the following additional options:

  • file.path - the path where the cache files are to be stored.
  • file.locking
use Joomla\Cache;

$options = array(
	'file.path' => __DIR__ . '/cache',
);

$cache = new Cache\File($options);

Memcached

use Joomla\Cache;

$cache = new Cache\Memcached;

None

use Joomla\Cache;

$cache = new Cache\None;

Runtime

use Joomla\Cache;

$cache = new Cache\Runtime;

Wincache

use Joomla\Cache;

$cache = new Cache\Wincache;

XCache

use Joomla\Cache;

$cache = new Cache\XCache;

Test Mocking

The Cache package provide a PHPUnit helper to mock a Cache\Cache object or an Cache\Item object. You can include your own optional overrides in the test class for the following methods:

  • Cache\Cache::get: Add a method called mockCacheGet to your test class. If omitted, the helper will return a default mock for the Cache\Item class.
  • Cache\Item::getValue: Add a method called mockCacheItemGetValue to your test class. If omitted, the mock Cache\Item will return "value" when this method is called.
  • Cache\Item::isHit: Add a method called mockCacheItemIsHit to your test class. If omitted, the mock Cache\Item will return false when this method is called.
use Joomla\Cache\Tests\Mocker as CacheMocker;

class FactoryTest extends \PHPUnit_Framework_TestCase
{
	private $instance;

	//
	// The following mocking methods are optional.
	//

	/**
	 * Callback to mock the Cache\Item::getValue method.
	 *
	 * @return  string
	 */
	public function mockCacheItemGetValue()
	{
		// This is the default handling.
		// You can override this method to provide a custom return value.
		return 'value';
	}

	/**
	 * Callback to mock the Cache\Item::isHit method.
	 *
	 * @return  boolean
	 */
	public function mockCacheItemIsHit()
	{
		// This is the default handling.
		// You can override this method to provide a custom return value.
		return false;
	}

	/**
	 * Callback to mock the Cache\Cache::get method.
	 *
	 * @param   string  $text  The input text.
	 *
	 * @return  string
	 */
	public function mockCacheGet($key)
	{
		// This is the default handling.
		// You can override this method to provide a custom return value.
		return $this->createMockItem();
	}

	protected function setUp()
	{
		parent::setUp();

		$mocker = new CacheMocker($this);

		$this->instance = new SomeClass($mocker->createMockCache());
	}
}

Installation via Composer

Add "alejoasotelo/joomla-cache-compat": "~1.0" to the require block in your composer.json and then run composer install.

{
	"require": {
		"alejoasotelo/joomla-cache-compat": "~1.0"
	}
}

Alternatively, you can simply run the following from the command line:

composer require alejoasotelo/joomla-cache-compat "~1.0"

alejoasotelo/joomla-cache-compat 适用场景与选型建议

alejoasotelo/joomla-cache-compat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 100 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 alejoasotelo/joomla-cache-compat 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 100
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2019-12-14