# Predis #
[![Software license][ico-license]](LICENSE)
[![Latest stable][ico-version-stable]][link-packagist]
[![Latest development][ico-version-dev]][link-packagist]
[![Monthly installs][ico-downloads-monthly]][link-downloads]
[![Build status][ico-travis]][link-travis]
[![HHVM support][ico-hhvm]][link-hhvm]
[![Gitter room][ico-gitter]][link-gitter]
Flexible and feature-complete [Redis](http://redis.io) client for PHP >= 5.3 and HHVM >= 2.3.0.
Predis does not require any additional C extension by default, but it can be optionally paired with
[phpiredis](https://github.com/nrk/phpiredis) to lower the overhead of the serialization and parsing
of the [Redis RESP Protocol](http://redis.io/topics/protocol). For an __experimental__ asynchronous
implementation of the client you can refer to [Predis\Async](https://github.com/nrk/predis-async).
More details about this project can be found on the [frequently asked questions](FAQ.md).
## Main features ##
- Support for different versions of Redis (from __2.0__ to __3.2__) using profiles.
- Support for clustering using client-side sharding and pluggable keyspace distributors.
- Support for [redis-cluster](http://redis.io/topics/cluster-tutorial) (Redis >= 3.0).
- Support for master-slave replication setups and [redis-sentinel](http://redis.io/topics/sentinel).
- Transparent key prefixing of keys using a customizable prefix strategy.
- Command pipelining on both single nodes and clusters (client-side sharding only).
- Abstraction for Redis transactions (Redis >= 2.0) and CAS operations (Redis >= 2.2).
- Abstraction for Lua scripting (Redis >= 2.6) and automatic switching between `EVALSHA` or `EVAL`.
- Abstraction for `SCAN`, `SSCAN`, `ZSCAN` and `HSCAN` (Redis >= 2.8) based on PHP iterators.
- Connections are established lazily by the client upon the first command and can be persisted.
- Connections can be established via TCP/IP (also TLS/SSL-encrypted) or UNIX domain sockets.
- Support for [Webdis](http://webd.is) (requires both `ext-curl` and `ext-phpiredis`).
- Support for custom connection classes for providing different network or protocol backends.
- Flexible system for defining custom commands and profiles and override the default ones.
## How to _install_ and use Predis ##
This library can be found on [Packagist](http://packagist.org/packages/predis/predis) for an easier
management of projects dependencies using [Composer](http://packagist.org/about-composer) or on our
[own PEAR channel](http://pear.nrk.io) for a more traditional installation using PEAR. Ultimately,
compressed archives of each release are [available on GitHub](https://github.com/nrk/predis/tags).
### Loading the library ###
Predis relies on the autoloading features of PHP to load its files when needed and complies with the
[PSR-4 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md).
Autoloading is handled automatically when dependencies are managed through Composer, but it is also
possible to leverage its own autoloader in projects or scripts lacking any autoload facility:
```php
// Prepend a base path if Predis is not available in your "include_path".
require 'Predis/Autoloader.php';
Predis\Autoloader::register();
```
It is also possible to create a [phar](http://www.php.net/manual/en/intro.phar.php) archive directly
from the repository by launching the `bin/create-phar` script. The generated phar already contains a
stub defining its own autoloader, so you just need to `require()` it to start using the library.
### Connecting to Redis ###
When creating a client instance without passing any connection parameter, Predis assumes `127.0.0.1`
and `6379` as default host and port. The default timeout for the `connect()` operation is 5 seconds:
```php
$client = new Predis\Client();
$client->set('foo', 'bar');
$value = $client->get('foo');
```
Connection parameters can be supplied either in the form of URI strings or named arrays. The latter
is the preferred way to supply parameters, but URI strings can be useful when parameters are read
from non-structured or partially-structured sources:
```php
// Parameters passed using a named array:
$client = new Predis\Client([
'scheme' => 'tcp',
'host' => '10.0.0.1',
'port' => 6379,
]);
// Same set of parameters, passed using an URI string:
$client = new Predis\Client('tcp://10.0.0.1:6379');
```
It is also possible to connect to local instances of Redis using UNIX domain sockets, in this case
the parameters must use the `unix` scheme and specify a path for the socket file:
```php
$client = new Predis\Client(['scheme' => 'unix', 'path' => '/path/to/redis.sock']);
$client = new Predis\Client('unix:/path/to/redis.sock');
```
The client can leverage TLS/SSL encryption to connect to secured remote Redis instances without the
need to configure an SSL proxy like stunnel. This can be useful when connecting to nodes running on
various cloud hosting providers. Encryption can be enabled with using the `tls` scheme and an array
of suitable [options](http://php.net/manual/context.ssl.php) passed via the `ssl` parameter:
```php
// Named array of connection parameters:
$client = new Predis\Client([
'scheme' => 'tls',
'ssl' => ['cafile' => 'private.pem', 'verify_peer' => true],
]);
// Same set of parameters, but using an URI string:
$client = new Predis\Client('tls://127.0.0.1?ssl[cafile]=private.pem&ssl[verify_peer]=1');
```
The connection schemes [`redis`](http://www.iana.org/assignments/uri-schemes/prov/redis) (alias of
`tcp`) and [`rediss`](http://www.iana.org/assignments/uri-schemes/prov/rediss) (alias of `tls`) are
also supported, with the difference that URI strings containing these schemes are parsed following
the rules described on their respective IANA provisional registration documents.
The actual list of supported connection parameters can vary depending on each connection backend so
it is recommended to refer to their specific documentation or implementation for details.
When an array of connection parameters is provided, Predis automatically works in cluster mode using
client-side sharding. Both named arrays and URI strings can be mixed when providing configurations
for each node:
```php
$client = new Predis\Client([
'tcp://10.0.0.1?alias=first-node',
['host' => '10.0.0.2', 'alias' => 'second-node'],
]);
```
See the [aggregate connections](#aggregate-connections) section of this document for more details.
Connections to Redis are lazy meaning that the client connects to a server only if and when needed.
While it is recommended to let the client do its own stuff under the hood, there may be times when
it is still desired to have control of when the connection is opened or closed: this can easily be
achieved by invoking `$client->connect()` and `$client->disconnect()`. Please note that the effect
of these methods on aggregate connections may differ depending on each specific implementation.
### Client configuration ###
Many aspects and behaviors of the client can be configured by passing specific client options to the
second argument of `Predis\Client::__construct()`:
```php
$client = new Predis\Client($parameters, ['profile' => '2.8', 'prefix' => 'sample:']);
```
Options are managed using a mini DI-alike container and their values can be lazily initialized only
when needed. The client options supported by default in Predis are:
- `profile`: specifies the profile to use to match a specific version of Redis.
- `prefix`: prefix string automatically applied to keys found in commands.
- `exceptions`: whether the client should throw or return responses upon Redis errors.
- `connections`: list of connection backends or a connection factory instance.
- `cluster`: specifies a cluster backend (`predis`, `redis` or callable object).
- `replication`: specifies a replication backend (`TRUE`, `sentinel` or callable object).
- `aggregate`: overrides `cluster` and `replication` to provide a custom conn
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目为FeelDesk工单管理系统的开源版(OS),是基于开发者版(DEV)分离的标准版;支持工单模版字段、工单状态等自定义,可为不同的模版设置不同的路由规则;对工单需求并不复杂的企业用户适用;FeelDesk推出多年来,获得了很多客户的认可,经历了千余次的迭代和升级,为了追求和应对更大规模和适应更复杂的应用,框架也从最初的ThinkPHP3.2.3升级到了ThinkPHP6,基于VUE的前端技术栈,以更稳定的服务和响应速度为用户提供SAAS服务
资源推荐
资源详情
资源评论
收起资源包目录
本项目为FeelDesk工单管理系统的开源版(OS),是基于开发者版(DEV)分离的标准版 (2794个子文件)
start_for_win.bat 78B
build 1KB
build 1KB
php_xxtea.c 6KB
xxtea.c 2KB
editableController.coffee 6KB
app.coffee 5KB
default.coffee 5KB
default_callbacks.spec.coffee 4KB
view.coffee 4KB
controller.coffee 4KB
settings.spec.coffee 4KB
events.spec.coffee 4KB
custom_callbacks.spec.coffee 2KB
apis.spec.coffee 2KB
textareaController.coffee 2KB
model.coffee 2KB
api.coffee 2KB
view.spec.coffee 1KB
spec_helper.coffee 1KB
content_editable.spec.coffee 1KB
iframe.spec.coffee 981B
COMMITMENT 2KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
config 1KB
COPYING 1KB
create-command-test 8KB
create-pear 7KB
create-phar 2KB
create-single-file 18KB
CREDITS 51B
style.css 115KB
iconfont.css 78KB
layui.css 73KB
mobile-date-feelcard.css 55KB
mobile-date.css 55KB
ticket-detail.css 47KB
index.css 22KB
common.css 19KB
feelecEditor.css 17KB
swiper.min.css 17KB
select2.css 16KB
feelecEditor.min.css 15KB
layer.css 14KB
layer.css 14KB
default-skin.css 11KB
login.css 11KB
jedate-feelcard.css 11KB
jedate.css 11KB
layui.mobile.css 10KB
lang2fonts.css 9KB
laydate.css 7KB
shCore.css 7KB
viewer.min.css 7KB
main.css 6KB
bootstrapStyle.css 6KB
layer.css 5KB
dtreefont.css 4KB
photoswipe.css 4KB
shThemeEclipse.css 4KB
pdf.css 4KB
shThemeFadeToGrey.css 3KB
shThemeRDark.css 3KB
shThemeDjango.css 3KB
shThemeMidnight.css 3KB
shThemeEmacs.css 3KB
public.css 3KB
shThemeDefault.css 3KB
select2-bootstrap.css 3KB
mobileSelect-feelcard.css 3KB
mobileSelect.css 3KB
dtree.css 3KB
uploadify.css 2KB
mpdf.css 2KB
style.css 2KB
webuploader.css 1KB
jquery.atwho.css 1KB
jquery.atwho.css 1KB
progbar.css 1KB
menu.css 1KB
code.css 1KB
notice.css 1KB
jquery.atwho.min.css 919B
style.css 853B
linebrdictK.dat 1MB
共 2794 条
- 1
- 2
- 3
- 4
- 5
- 6
- 28
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7364
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- C#winform-通用的视觉框架【功能完善,界面美观】,左侧工具栏,右边图像,右下日志,顶部导航栏,底部变量信息等等
- C#产品成本测算系统源码 成本管理系统源码数据库 SQL2008源码类型 WinForm
- C#多线程与线程同步机制高级实战课程
- 24129398王一钞.zip
- java项目,课程设计-ssm-宝康药房销售管理系统.zip
- 技术资料分享以太网开发入门很好的技术资料.zip
- HTML5实现趣味飞船捡金币小游戏源码
- 技术资料分享一种基于PWM的电压输出DAC电路设计很好的技术资料.zip
- java项目,课程设计-#ssm-mysql-记账管理系统.zip
- 技术资料分享使用SAM-BA更新jlink固件很好的技术资料.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功