tscms / cache
官方Kohana缓存管理模块
v3.3.4
2015-06-27 06:18 UTC
Requires
- php: >=5.3.3
- composer/installers: ~1.0
- kohana/core: >=3.3
Requires (Dev)
- kohana/core: 3.3.*@dev
- kohana/koharness: *@dev
- kohana/unittest: 3.3.*@dev
This package is not auto-updated.
Last update: 2024-09-18 09:21:15 UTC
README
Kohana 3的缓存库提供了一个简单的接口,用于最常用的缓存解决方案。开发者可以自由添加遵循此模块内定义的缓存设计模式的自定义缓存解决方案。
支持的缓存解决方案
目前此模块支持以下缓存方法。
- APC
- Memcache
- Memcached-tags(支持标签)
- SQLite(支持标签)
- 文件
- Wincache
计划支持
在不久的将来,将包括以下方法的额外支持。
- Memcached
缓存介绍
为了最大限度地使用缓存,您的应用程序应该从设计之初就考虑缓存。一般来说,最有效的缓存包含大量由昂贵的计算操作(如搜索大型数据集)生成的小数据集。
PHP有多种不同的缓存方法,从基本的基于文件的缓存到eAccelerator和APC中的代码缓存。使用物理内存而不是基于磁盘的存储的缓存引擎总是更快,但是许多引擎不支持更高级的功能,如标签。
使用缓存
要使用Kohana Cache,请从Github下载并提取Kohana Cache的最新稳定版本。将模块放入您的Kohana实例模块文件夹中。最后,在应用引导中的模块部分中启用模块。
快速示例
以下是一个使用Kohana Cache的快速示例。示例使用SQLite驱动程序。
<?php
// Get a Sqlite Cache instance
$mycache = Cache::instance('sqlite');
// Create some data
$data = array('foo' => 'bar', 'apples' => 'pear', 'BDFL' => 'Shadowhand');
// Save the data to cache, with an id of test_id and a lifetime of 10 minutes
$mycache->set('test_id', $data, 600);
// Retrieve the data from cache
$retrieved_data = $mycache->get('test_id');
// Remove the cache item
$mycache->delete('test_id');
// Clear the cache of all stored items
$mycache->delete_all();