kohana / cache
官方 Kohana 缓存管理模块
v3.3.6
2016-03-30 09:53 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
- dev-3.3/master
- dev-3.4/develop / 3.4.x-dev
- dev-3.3/develop / 3.3.x-dev
- v3.3.6
- v3.3.5
- v3.3.4
- v3.3.3.1
- v3.3.3
- v3.3.2
- v3.3.1
- v3.2.3
- dev-3.3/bug/apcu-inc-dec-compatibility
- dev-merge/3.3-develop-3.4
- dev-3.3/test/migrate-travis-container-based
- dev-3.3/test/phpunit-version-lowest
- dev-3.3/feat/reinstate-hhvm-tests
- dev-3.4/feat/travis-module-builds
This package is auto-updated.
Last update: 2024-09-11 14:38:20 UTC
README
Kohana 3 缓存库提供了一个简单接口,用于最常见的缓存解决方案。开发者可以自由添加遵循此模块内定义的缓存设计模式的自己的缓存解决方案。
支持的缓存解决方案
目前此模块支持以下缓存方法。
- APC
- Memcache
- Memcached-tags(支持标签)
- SQLite(支持标签)
- 文件
- Wincache
计划支持
在不久的将来,将包括对以下方法的额外支持。
- Memcached
缓存介绍
为了最大限度地利用缓存,您的应用程序应该从一开始就考虑缓存设计。一般来说,最有效的缓存包含大量由昂贵的计算操作(如搜索大量数据集)生成的小数据集合。
PHP有很多不同的缓存方法可用,从非常基本的基于文件的缓存到 eAccelerator 和 APC 中的 opcode 缓存。使用物理内存而不是基于磁盘存储的缓存引擎总是更快,然而许多不支持更高级的功能,如标签。
使用缓存
要使用 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();