for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Webdcg\Redis\Traits;
trait Transactions
{
/**
* Marks the start of a transaction block. Subsequent commands will be
* queued for atomic execution using EXEC.
* See: https://redis.io/commands/multi.
*
* @return transaction context
*/
public function multi()
return $this->redis->multi();
redis
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Executes all previously queued commands in a transaction and restores
* the connection state to normal.
* See: https://redis.io/commands/exec.
* @return array each element being the reply to each of the commands
* in the atomic transaction.
public function exec($multi): array
return $multi->exec();
* Flushes all previously queued commands in a transaction and restores the
* connection state to normal.
* See: https://redis.io/commands/discard.
* @param $multi
* @return bool
public function discard(\Redis $multi): bool
return $multi->discard();
* Marks the given keys to be watched for conditional execution of a
* transaction.
* See: https://redis.io/commands/watch.
* @param splat $keys
public function watch(...$keys): bool
return $this->redis->watch(...$keys);
* Flushes all the previously watched keys for a transaction.
* If you call EXEC or DISCARD, there's no need to manually call UNWATCH.
* See: https://redis.io/commands/unwatch.
public function unwatch(...$keys): bool
return $this->redis->unwatch(...$keys);
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: