[![Code Climate](https://codeclimate.com/github/PHPSocialNetwork/phpfastcache/badges/gpa.svg)](https://codeclimate.com/github/PHPSocialNetwork/phpfastcache) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/PHPSocialNetwork/phpfastcache/badges/quality-score.png?b=final)](https://scrutinizer-ci.com/g/PHPSocialNetwork/phpfastcache/?branch=final) [![Build Status](https://travis-ci.org/PHPSocialNetwork/phpfastcache.svg?branch=final)](https://travis-ci.org/PHPSocialNetwork/phpfastcache) [![Latest Stable Version](http://img.shields.io/packagist/v/phpfastcache/phpfastcache.svg)](https://packagist.org/packages/phpfastcache/phpfastcache) [![Total Downloads](http://img.shields.io/packagist/dt/phpfastcache/phpfastcache.svg)](https://packagist.org/packages/phpfastcache/phpfastcache) [![Dependency Status](https://www.versioneye.com/php/phpfastcache:phpfastcache/badge.svg)](https://www.versioneye.com/php/phpfastcache:phpfastcache) [![License](https://img.shields.io/packagist/l/phpfastcache/phpfastcache.svg)](https://packagist.org/packages/phpfastcache/phpfastcache) [![Coding Standards](https://img.shields.io/badge/CI-PSR6-orange.svg)](https://github.com/php-fig/cache)
:exclamation: V4 USERS, PLEASE SEE THE README !! V5 IS OFFICIALY OUT !! YOUR CODE NEEDS TO BE [REWRITTEN](https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV4%5D-Migrating-your-code-to-the-V5) :exclamation:
---------------------------
Simple Yet Powerful PHP Caching Class
---------------------------
More information in [Wiki](https://github.com/PHPSocialNetwork/phpfastcache/wiki)
One Class uses for All Cache. You don't need to rewrite your code many times again.
### Supported drivers at this day *
:bulb: Feel free to propose a driver by making a new **Pull Request**, they are welcome !
| Regular drivers | High performances drivers | Development driver |
|--------------------|---------------------------|--------------------|
| `Apc(u)` | `CouchBase` | `Devnull` |
| `Cookie` | `Mongodb` | `Devfalse` |
| `Files` | `Predis` | `Devtrue` |
| `Leveldb` | `Redis` | |
| `Memcache(d)` | `Ssdb` | |
| `Sqlite` | `Zend Memory Cache` | |
| `Wincache` | | |
| `Xcache` | | |
| `Zend Disk Cache` | | |
\* Driver descriptions available in DOCS/DRIVERS.md
### Symfony/Drupal developers are not forgotten !
Starting with v5, phpFastCache comes with a [Symfony Bundle](https://github.com/PHPSocialNetwork/phpfastcache-bundle).
It's fresh, so feel free to report any bug or contribute to the project using pull requests.
Also a [Drupal 8 Module](https://github.com/PHPSocialNetwork/phpfastcache-drupal) is currently in development, add it to your starred projects to get notified of the first public release.
---------------------------
Not a "Traditional" Caching
---------------------------
phpFastCache is not like the traditional caching methods which keep reading and writing to files, sqlite or keeping open massive amounts of connections to memcache, redis, mongodb... Also, when you use Memcache / Memcached, your miss hits will be reduced.
Different from the usual caching methods you'll find everywhere on the internet, the phpFastCache library reduces high I/O load, and is faster than the traditional caching methods by at least ~7 times.
However, when you still want to use traditional caching methods, we support them too.
```php
use phpFastCache\CacheManager;
CacheManager::getInstance('files', $config);
// An alternative exists:
CacheManager::Files($config);
```
---------------------------
Reduce Database Calls
---------------------------
Your website has 10,000 visitors who are online, and your dynamic page has to send 10,000 times the same queries to database on every page load.
With phpFastCache, your page only sends 1 query to your DB, and uses the cache to serve the 9,999 other visitors.
---------------------------
Rich Development API
---------------------------
phpFastCache offers you a lot of useful APIs:
### Item API
- getKey() // Returns the item identifier (key)
- get() // The getter, obviously, returns your cache object
- set($value) // The setter, for those who missed it, putting 0 means cache it forever
- expiresAfter($ttl) // Allow you to extend the lifetime of an entry without altering its value (formerly known as touch())
- expiresAt($expiration) // Sets the expiration time for this cache item (as a DateTimeInterface object)
- increment($step = 1) // To allow us to count on an integer item
- decrement($step = 1) // Redundant joke...
- append($data) // Appends data to a string or an array (push)
- prepend($data) // Prepends data to a string or an array (unshift)
- isHit() // Checks if your cache entry exists and is still valid, it's the equivalent of isset()
- isExpired() // Checks if your cache entry is expired
- getTtl() // Gets the remaining Time To Live as an integer
- getExpirationDate() // Gets the expiration date as a Datetime object
- addTag($tagName) // Adds a tag
- addTags(array $tagNames) // Adds multiple tags
- setTags(array $tags) // Sets multiple tags
- getTags() // Gets the tags
- getTagsAsString($separator = ', ') // Gets the data as a string separated by $separator
- removeTag($tagName) // Removes a tag
- removeTags(array $tagNames) // Removes some tags
- getDataAsJsonString()// Returns the data as a well-formatted json string
### ItemPool API
- getItem($key) // Retrieves an item and returns an empty item if not found
- getItems(array $keys) // Retrieves one or more items and returns an array of items
- getItemsAsJsonString(array $keys) // Returns a json string that represents an array of items
- hasItem($key) // Tests if an item exists
- deleteItem($key) // Deletes an item
- deleteItems(array $keys) // Deletes one or more items
- save(CacheItemInterface $item) // Persists a cache item immediately
- saveDeferred(CacheItemInterface $item); // Sets a cache item to be persisted later
- commit(); // Persists any deferred cache items
- clear() // Allows you to completely empty the cache
- getStats() // Returns the cache statistics as an object, useful for checking disk space used by the cache etc.
- getItemsByTag($tagName) // Returns items by a tag
- getItemsByTags(array $tagNames) // Returns items by multiple tags
- getItemsByTagsAsJsonString(array $tagNames) // Returns a json string that represents an array of items corresponding to given tags
- deleteItemsByTag($tagName) // Deletes items by a tag
- deleteItemsByTags(array $tagNames) // Deletes items by multiple tags
- incrementItemsByTag($tagName, $step = 1) // Increments items by a tag
- incrementItemsByTags(array $tagNames, $step = 1) // Increments items by multiple tags
- decrementItemsByTag($tagName, $step = 1) // Decrements items by a tag
- decrementItemsByTags(array $tagNames, $step = 1) // Decrements items by multiple tags
- appendItemsByTag($tagName, $data) // Appends items by a tag
- appendItemsByTags(array $tagNames, $data) // Appends items by multiple tags
- prependItemsByTag($tagName, $data) // Prepends items by a tag
- prependItemsByTags(array $tagNames, $data) // Prepends items by multiple tags
- detachItem($item) // Detaches an item from the pool
- detachAllItems($item) // Detaches all items from the pool
- attachItem($item) // (Re-)attaches an item to the pool
- isAttached($item) // Verifies if an item is (still) attached
It also supports Multiple calls, Tagging, Setup Folder for caching. Look at our examples folders for more information.
---------------------------
As Fast To Implement As Opening a Beer
---------------------------
#### :thumbsup: Step 1: Include phpFastCache in your project with composer:
```bash
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
PHPFastCache:开源的PHP缓存库 (119个子文件)
CNAME 20B
.gitignore 3KB
.htaccess 51B
index.html 101B
phpfastcache.ini 63B
composer.json 2KB
composer.json 513B
LICENCE 1KB
composer.lock 6KB
README.md 10KB
DRIVERS.md 2KB
CONTRIBUTING.md 1KB
README.md 277B
ISSUE_TEMPLATE.md 194B
README.md 71B
Driver.php 12KB
ExtendedCacheItemPoolInterface.php 11KB
ExtendedCacheItemPoolTrait.php 10KB
ItemBaseTrait.php 10KB
CacheManager.php 9KB
DriverBaseTrait.php 8KB
PathSeekerTrait.php 8KB
StandardPsr6StructureTrait.php 7KB
Driver.php 7KB
Driver.php 6KB
Driver.php 6KB
Driver.php 5KB
Driver.php 5KB
driverStatistic.php 5KB
Driver.php 5KB
Driver.php 5KB
Driver.php 5KB
Driver.php 4KB
Driver.php 4KB
CacheItemPoolInterface.php 4KB
stub.php 4KB
Directory.php 4KB
Driver.php 4KB
Driver.php 4KB
ExtendedCacheItemInterface.php 4KB
CacheItemInterface.php 4KB
Driver.php 4KB
Driver.php 4KB
Driver.php 3KB
Driver.php 3KB
phpFastCacheAbstractProxy.php 3KB
Driver.php 3KB
Driver.php 3KB
Driver.php 3KB
ReadWriteOperations.test.php 2KB
tagsMethods.php 2KB
Github-392.test.php 2KB
AttachingDetachingMethods.test.php 2KB
Api.php 2KB
memcache.php 2KB
Item.php 2KB
Item.php 2KB
Item.php 2KB
Item.php 2KB
sqlite.php 2KB
Item.php 2KB
Item.php 2KB
Item.php 2KB
Item.php 2KB
Item.php 2KB
Item.php 2KB
Item.php 2KB
Item.php 2KB
DriverAbstract.php 2KB
Item.php 2KB
Item.php 2KB
Item.php 2KB
files.php 2KB
Item.php 2KB
Item.php 2KB
Item.php 2KB
Item.php 2KB
AbstractProxy.test.php 2KB
Item.php 2KB
memcached.php 2KB
couchbase.php 2KB
autoload.php 1KB
zend_disk.php 1KB
TestingFunctions.php 1KB
decrement.php 1KB
increment.php 1KB
ssdb.php 1KB
SyntaxChecker.test.php 1KB
run_tests.php 1KB
Languages.php 1KB
extendedPhpFastCache.php 1KB
mongodb.php 1KB
legacy.php 1KB
cookie.php 1KB
predis.php 1KB
xcache.php 1KB
redis.php 1KB
apc.php 1KB
zend_shm.php 1KB
Psr6InterfaceImplements.test.php 1KB
共 119 条
- 1
- 2
资源评论
reg183
- 粉丝: 1811
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功