|
1 | | -### Keys |
| 1 | +# Valkey PHP - Keys |
| 2 | + |
2 | 3 | ----- |
3 | 4 |
|
| 5 | +|Command |Description |Supported |Tested |Class/Trait |Method | |
| 6 | +|--- |--- |:-: |:-: |--- |--- | |
| 7 | +|[del](#del) |Delete a key [Blocking] |:white\_check\_mark: |:white\_check\_mark: |Keys |del | |
| 8 | +|[delete](#delete) |Delete a key [Blocking] |:white\_check\_mark: |:white\_check\_mark: |Keys |delete | |
| 9 | +|[dump](#dump) |Return a serialized version of the value stored at the specified key. |:white\_check\_mark: |:white\_check\_mark: |Keys |dump | |
| 10 | +|[exists](#exists) |Determine if a key exists |:white\_check\_mark: |:white\_check\_mark: |Keys |exists | |
| 11 | +|[expire](#expire) |Set a key's time to live in seconds |:white\_check\_mark: |:white\_check\_mark: |Keys |expire | |
| 12 | +|[expireAt](#expireAt) |Set the expiration for a key as a UNIX timestamp |:white\_check\_mark: |:white\_check\_mark: |Keys |pexpireAt | |
| 13 | +|[getKeys](#getKeys) |Find all keys matching the given pattern |:white\_check\_mark: |:white\_check\_mark: |Keys |getKeys | |
| 14 | +|[keys](#keys) |Find all keys matching the given pattern |:white\_check\_mark: |:white\_check\_mark: |Keys |keys | |
| 15 | +|[migrate](#migrate) | Atomically transfer a key from a Redis instance to another one |:white\_check\_mark: |:white\_check\_mark: |Keys |migrate | |
| 16 | +|[move](#move) | Move a key to another database |:white\_check\_mark: |:white\_check\_mark: |Keys |move | |
| 17 | +|[object](#object) | Inspect the internals of Redis objects |:white\_check\_mark: |:white\_check\_mark: |Keys |object | |
| 18 | +|[persist](#persist) | Remove the expiration from a key |:white\_check\_mark: |:white\_check\_mark: |Keys |persist | |
| 19 | +|[pexpire](#pexpire) |Set a key's time to live in seconds |:white\_check\_mark: |:white\_check\_mark: |Keys |pexpire | |
| 20 | +|[pexpireAt](#pexpireAt) |Set the expiration for a key as a UNIX timestamp with millisecond precision |:white\_check\_mark: |:white\_check\_mark: |Keys |pexpireAt | |
| 21 | +|[pttl](#pttl) | Get the time to live for a key |:white\_check\_mark: |:white\_check\_mark: |Keys |pttl | |
| 22 | +|[randomKey](#randomKey) | Return a random key from the keyspace |:white\_check\_mark: |:white\_check\_mark: |Keys |randomKey | |
| 23 | +|[rename](#rename) | Rename a key |:white\_check\_mark: |:white\_check\_mark: |Keys |rename | |
| 24 | +|[renameKey](#renameKey) | Rename a key |:white\_check\_mark: |:white\_check\_mark: |Keys |renameKey | |
| 25 | +|[renameNx](#renameNx) | Rename a key, only if the new key does not exist |:white\_check\_mark: |:white\_check\_mark: |Keys |renameNx | |
| 26 | +|[restore](#restore) | Create a key using the provided serialized value, previously obtained with dump. |:white\_check\_mark: |:white\_check\_mark: |Keys |restore | |
| 27 | +|[scan](#scan) | Scan for keys in the keyspace (Redis >= 2.8.0) |:white\_check\_mark: |:white\_check\_mark: |Keys |scan | |
| 28 | +|[setTimeout](#setTimeout) |Set a key's time to live in seconds |:white\_check\_mark: |:white\_check\_mark: |Keys |setTimeout | |
| 29 | +|[sort](#sort) | Sort the elements in a list, set or sorted set |:white\_check\_mark: |:white\_check\_mark: |Keys |sort | |
| 30 | +|[ttl](#ttl) | Get the time to live for a key |:white\_check\_mark: |:white\_check\_mark: |Keys |ttl | |
| 31 | +|[type](#type) | Determine the type stored at key |:white\_check\_mark: |:white\_check\_mark: |Keys |type | |
| 32 | +|[unlink](#unlink) |Delete a key [Background] |:white\_check\_mark: |:white\_check\_mark: |Keys |unlink | |
| 33 | + |
4 | 34 | * [del, delete, unlink](#del-delete-unlink) - Delete a key |
5 | 35 | * [dump](#dump) - Return a serialized version of the value stored at the specified key. |
6 | 36 | * [exists](#exists) - Determine if a key exists |
|
20 | 50 | * [ttl, pttl](#ttl-pttl) - Get the time to live for a key |
21 | 51 | * [restore](#restore) - Create a key using the provided serialized value, previously obtained with [dump](#dump). |
22 | 52 |
|
| 53 | +## Usage |
| 54 | + |
| 55 | +```php |
| 56 | +$valkey = new Valkey(); |
| 57 | +$valkey->connect('127.0.0.1', 6379); |
| 58 | +$valkey->del('key'); |
| 59 | +$valkey->delete('key'); |
| 60 | +$valkey->unlink('key'); |
| 61 | +$valkey->dump('key'); |
| 62 | +$valkey->exists('key'); |
| 63 | +$valkey->expire('key', 123); |
| 64 | +$valkey->expireAt('key', 1743016214.623306); |
| 65 | +$valkey->keys(); |
| 66 | +$valkey->scan(); |
| 67 | +$valkey->migrate('key'); |
| 68 | +$valkey->move('key'); |
| 69 | +$valkey->object('key'); |
| 70 | +$valkey->persist('key'); |
| 71 | +$valkey->randomKey('key'); |
| 72 | +$valkey->rename('key', 'yek'); |
| 73 | +$valkey->renameNx('key', 'yek'); |
| 74 | +$valkey->type('key'); |
| 75 | +$valkey->sort('key'); |
| 76 | +$valkey->ttl('key'); |
| 77 | +$valkey->restore('key'); |
| 78 | +``` |
| 79 | + |
23 | 80 | ### dump |
24 | 81 | ----- |
25 | 82 | _**Description**_: Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command. The data |
|
0 commit comments