Download the PHP package colinmollenhour/credis without Composer

On this page you can find all versions of the php package colinmollenhour/credis. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package credis

Build Status

Credis

Credis is a lightweight interface to the Redis key-value store which wraps the phpredis library when available for better performance. This project was forked from one of the many redisent forks.

Getting Started

Credis_Client uses methods named the same as Redis commands, and translates return values to the appropriate PHP equivalents.

Redis error responses will be wrapped in a CredisException class and thrown.

Credis_Client also supports transparent command renaming. Write code using the original command names and the client will send the aliased commands to the server transparently. Specify the renamed commands using a prefix for md5, a callable function, individual aliases, or an array map of aliases. See "Redis Security":http://redis.io/topics/security for more info.

Supported connection string formats

Unix socket connection string

unix:///path/to/redis.sock

TCP connection string

tcp://host[:port][/persistence_identifier]

TLS connection string

tls://host[:port][/persistence_identifier]

or

tlsv1.2://host[:port][/persistence_identifier]

Before php 7.2, tls:// only supports TLSv1.0, either ssl:// or tlsv1.2 can be used to force TLSv1.2 support.

Recent versions of redis do not support the protocols/cyphers that older versions of php default to, which may result in cryptic connection failures.

Enable transport level security (TLS)

Use TLS connection string tls://127.0.0.1:6379 instead of TCP connection tcp://127.0.0.1:6379 string in order to enable transport level security.

Clustering your servers

Credis also includes a way for developers to fully utilize the scalability of Redis with multiple servers and consistent hashing. Using the Credis_Cluster class, you can use Credis the same way, except that keys will be hashed across multiple servers. Here is how to set up a cluster:

Basic clustering example

Explicit definition of replicas

The consistent hashing strategy stores keys on a so called "ring". The position of each key is relative to the position of its target node. The target node that has the closest position will be the selected node for that specific key.

To avoid an uneven distribution of keys (especially on small clusters), it is common to duplicate target nodes. Based on the number of replicas, each target node will exist n times on the "ring".

The following example explicitly sets the number of replicas to 5. Both Redis instances will have 5 copies. The default value is 128.

Master/slave replication

The master/slave replication. Credis_Cluster will automatically perform read/write splitting and send the write requests exclusively to the master server. Read requests will be handled by all servers unless you set the write_only flag to true in the connection string of the master server.

Redis server settings for master/slave replication

Setting up master/slave replication is simple and only requires adding the following line to the config of the slave server:

Basic master/slave example

No read on master

The following example illustrates how to disable reading on the master server. This will cause the master server only to be used for writing. This should only happen when you have enough write calls to create a certain load on the master server. Otherwise this is an inefficient usage of server resources.

Automatic failover with Sentinel

Redis Sentinel is a system that can monitor Redis instances. You register master servers and Sentinel automatically detects its slaves.

When a master server dies, Sentinel will make sure one of the slaves is promoted to be the new master. This autofailover mechanism will also demote failed masters to avoid data inconsistency.

The Credis_Cluster objects and will set the master and slaves accordingly.

Sentinel uses the same protocol as Redis. In the example below we register the Sentinel server running on port 26379 and assign it to the Credis_Sentinel object. We then ask Sentinel the hostname and port for the master server known as mymaster. By calling the getCluster method we immediately get a Credis_Cluster object that allows us to perform basic Redis calls.

Additional parameters

Because Credis_Cluster objects using the "getCluster" or "createCluster" methods, additional parameters can be passed.

First of all there's the "write_only" flag. You can also define the selected database and the number of replicas. And finally there's a "selectRandomSlave" option.

The "selectRandomSlave" flag is used in setups for masters that have multiple slaves. The Credis_Sentinel will either select one random slave to be used when creating the Credis_Cluster object or to pass them all and use the built-in hashing.

The example below shows how to use these 3 options. It selects database 2, sets the number of replicas to 10, it doesn't select a random slave and doesn't allow reading on the master server.

About

© 2011 Colin Mollenhour © 2009 Justin Poliey


All versions of credis with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package colinmollenhour/credis contains the following files

Loading the files please wait ....