-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathredis_example.dc
57 lines (44 loc) · 1.21 KB
/
redis_example.dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"redis.dc" import
# connect to the server
redis_connect
"
Illustration of redis interface, which for now is limited to the simplest
setting and getting of top-level keys.
"
print cr
# Illustrate simple key setting and getting
# STRING
"To set the key \"Foo\" to the value \"Bar\", one calls the following:
\"Bar\" \"Foo\" redis_set print cr
Notice that the value precedes the key, consistent with the idea that
a key to be fetched would immediately precede the operator doing the fetching,
and thus, the value to be set would preced _that_. So, <val> <key> <operator>
would be the natural order in a stack-based language like `dclang`.
"
print cr
# END STRING
# CODE
"Bar" "Foo" redis_set print cr
# END CODE
# STRING
"Now, to fetch the value we have set, we simply do:
\"Foo\" redis_get print cr
"
print cr
# END STRING
# CODE
"Foo" redis_get print cr
cr
# END CODE
# STRING
"Next, we'll do a simlar set/get, but with the great J.S. Bach as the subject
of interest. The following is the output of two commands in succession:
\"Bach\" \"Best_composer\" redis_set print cr
\"Best_composer\" redis_get print cr
"
print cr
# END STRING
# CODE
"Bach" "Best_composer" redis_set print cr
"Best_composer" redis_get print cr
# END CODE