Skip to content

Commit f0401de

Browse files
author
Roberto Luna Rojas
committed
Documentation | Keys
1 parent a47e0bd commit f0401de

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,28 @@ $valkey->getAuth();
242242
### [Keys](docs/content/keys.md)
243243

244244
```php
245+
$valkey = new Valkey();
246+
$valkey->connect('127.0.0.1', 6379);
245247
$valkey->del('key');
246248
$valkey->delete('key');
247249
$valkey->unlink('key');
250+
$valkey->dump('key');
251+
$valkey->exists('key');
252+
$valkey->expire('key', 123);
253+
$valkey->expireAt('key', 1743016214.623306);
254+
$valkey->keys();
255+
$valkey->scan();
256+
$valkey->migrate('key');
257+
$valkey->move('key');
258+
$valkey->object('key');
259+
$valkey->persist('key');
260+
$valkey->randomKey('key');
261+
$valkey->rename('key', 'yek');
262+
$valkey->renameNx('key', 'yek');
263+
$valkey->type('key');
264+
$valkey->sort('key');
265+
$valkey->ttl('key');
266+
$valkey->restore('key');
248267
```
249268

250269
### [Lists](docs/content/lists.md)

docs/content/keys.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
1-
### Keys
1+
# Valkey PHP - Keys
2+
23
-----
34

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+
434
* [del, delete, unlink](#del-delete-unlink) - Delete a key
535
* [dump](#dump) - Return a serialized version of the value stored at the specified key.
636
* [exists](#exists) - Determine if a key exists
@@ -20,6 +50,33 @@
2050
* [ttl, pttl](#ttl-pttl) - Get the time to live for a key
2151
* [restore](#restore) - Create a key using the provided serialized value, previously obtained with [dump](#dump).
2252

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+
2380
### dump
2481
-----
2582
_**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

Comments
 (0)