Skip to content

Commit 3807a7a

Browse files
Update strings.md
1 parent 95327ee commit 3807a7a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/ds/strings.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Redis strings are used to store strings, numbers, images, serialized objects, an
22

33
As a first example, use the `SET` command to store the value "Deimos", a type of bike, at key "bike:1".
44

5-
```redis Create a new key
5+
```redis:[run_confirmation=true] Create a new key
66
SET bike:1 "Deimos"
77
```
88

@@ -23,7 +23,7 @@ The `EXISTS` command returns `1` when a key exists and `0` when it does not exis
2323

2424
Use the `DEL` to delete a key and its data.
2525

26-
```redis Delete bike:1
26+
```redis:[run_confirmation=true] Delete bike:1
2727
DEL bike:1
2828
EXISTS bike:1
2929
```
@@ -37,24 +37,24 @@ If you store integer data in a string key, you can use these commands to increme
3737
- `DECR` - decrement a number stored in a key by `2`.
3838
- `DECRBY` - decrement a number stored in a key by a specific positive or negative amount.
3939

40-
```redis INCR usage
40+
```redis:[run_confirmation=true] INCR usage
4141
SET bikes:total_number 10
4242
INCR bikes:total_number
4343
INCR bikes:total_number
4444
```
4545

46-
```redis Use INCR to set a key to 1
46+
```redis:[run_confirmation=true] Use INCR to set a key to 1
4747
DEL bikes:total_number
4848
INCR bikes:total_number
4949
```
5050

5151
Note how the `INCR bikes:total_number` command that follows the `DEL` command re-creates the `bikes:total_number` key and sets its value to `1`.
5252

53-
```redis INCRBY usage
53+
```redis:[run_confirmation=true] INCRBY usage
5454
INCRBY bikes:total_number 100
5555
```
5656

57-
```redis DECR and DECRBY usage
57+
```redis:[run_confirmation=true] DECR and DECRBY usage
5858
DECR bikes:total_number
5959
DECRBY bikes:total_number 10
6060
```
@@ -67,7 +67,7 @@ All the Redis operations implemented by single commands are atomic, including th
6767

6868
When keys are created without constraints, they live for the full lifespan of the Redis server to which they are attached. However, if you want a key to live for only a specific amount of time, you can use the `EXPIRE` command to alter its lifespan. To find out how much time is left before a key expires, use the `TTL` command.
6969

70-
```redis EXPIRE usage
70+
```redis:[run_confirmation=true] EXPIRE usage
7171
SET bike:1:lock_status "LOCKED"
7272
EXPIRE bike:1:lock_status 20
7373
```
@@ -85,7 +85,7 @@ You'll see one of the two return values:
8585

8686
If you try to use the `TTL` command on a key that does not have an expiration set, it will return `-1`.
8787

88-
```redis TTL on a non-expiring key
88+
```redis:[run_confirmation=true] TTL on a non-expiring key
8989
SET bike:2:lock_status "LOCKED"
9090
TTL bike:2:lock_status
9191
```
@@ -94,13 +94,13 @@ TTL bike:2:lock_status
9494

9595
The `SET` command can take additional arguments, one of which allows you to set the value of a key and its time to live value directly in a single, atomic operation. The `EX` and `PX` arguments allow you to specify the TTL value as either seconds or milliseconds, respectively.
9696

97-
```redis SET with time to live
97+
```redis:[run_confirmation=true] SET with time to live
9898
SET bike:1:lock_status "LOCKED" PX 1
9999
```
100100

101101
It's possible to cancel a key's timeout using the `PERSIST` command.
102102

103-
```redis PERSIST usage
103+
```redis:[run_confirmation=true] PERSIST usage
104104
SET bike:1:lock_status "LOCKED" EX 120
105105
PERSIST bike:1:lock_status
106106
TTL bike:1:lock_status

0 commit comments

Comments
 (0)