PHP code example of llegaz / redis-ultimate

1. Go to this page and download the library: Download llegaz/redis-ultimate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

llegaz / redis-ultimate example snippets


sadd(string $key, mixed ...$members): int      // Add one or more members
srem(string $key, mixed ...$members): int      // Remove one or more members
smembers(string $key): array                   // Return all members
sismember(string $key, mixed $member): bool    // Check if a member exists
scard(string $key): int                        // Count members

sinter(string ...$keys): array                 // Intersection
sunion(string ...$keys): array                 // Union
sdiff(string $key, string ...$keys): array     // Difference

zadd(string $key, mixed ...$members): int      // Add one or more members
zrem(string $key, mixed ...$members): int      // Remove one or more members
zrange(string $key): array                   // Return all members
zcard(string $key): int                        // Count members

rpush(string $key, mixed ...$values): int      // Producer: push a message
lpop(string $key): mixed                       // Non-blocking consumer
lmpop(string $key): array
llen(string $key): int                         // Queue length

publish(string $channel, mixed $message): int          // Publish a message
subscribe(string ...$channels): void                   // Subscribe to channels
unsubscribe(string ...$channels): void                 // Unsubscribe
psubscribe(string ...$patterns): void                  // Pattern matching e.g. "user.*"

// * = auto-generated id
xadd(string $key, array $message, string $id = '*'): string

// Simple read
xread(array $streams, int $count = null, int $block = null): array

// Read via consumer group
xreadgroup(string $group, string $consumer, array $streams, int $count = null): array

// Acknowledge a processed message
xack(string $key, string $group, string ...$ids): int

// Manage consumer groups
xgroup(string $op, string $key, string $group, string $id = '0'): mixed

// Number of messages in the stream
xlen(string $key): int