PHPackages                             angyvolin/predis-commands - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. angyvolin/predis-commands

ActiveLibrary[Caching](/categories/caching)

angyvolin/predis-commands
=========================

Adds some useful commands to Predis.

0.1.3(9y ago)13.2kMITPHP

Since Apr 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/angyvolin/predis-commands)[ Packagist](https://packagist.org/packages/angyvolin/predis-commands)[ RSS](/packages/angyvolin-predis-commands/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (5)Used By (0)

predis-commands
===============

[](#predis-commands)

Adds some [Lua](https://www.lua.org/)-based atomic commands to [Predis](https://github.com/nrk/predis).

Motivation
----------

[](#motivation)

Any individual Redis command is always atomic because Redis is single threaded. In some cases you may want to run several Redis commands atomically.

There are two common ways to achieve this:

- [Redis transactions](https://redis.io/topics/transactions). It utilizes `MULTI`/`EXEC` Redis commands to run some commands in sequence It also uses `WATCH`/`DISCARD` Redis commands for `CAS` optimistic concurrency.
- [Redis scripts](https://redis.io/commands/eval). This one is transactional by definition: Redis uses the same Lua interpreter to run all the commands and guarantees that no other script or Redis command will be executed while a script is being executed.

This project uses Lua Scripting approach as it's usually both simpler and faster.

Installation
------------

[](#installation)

```
composer require angyvolin/predis-commands

```

What's included?
----------------

[](#whats-included)

As of now, the `predis-commands` project extends Predis with following commands:

```
ZPOP - Removes and returns the top value in a zset, with its score.
ZRPOP - Removes and returns the bottom value in a zset, with its score.

```

How to use predis-commands ...
------------------------------

[](#how-to-use-predis-commands-)

### ... in plain PHP

[](#-in-plain-php)

Code snippet below demonstrates how to use `predis-commands` regardless of any framework

```
