1 /*
2 * Hunt - A redis client library for D programming language.
3 *
4 * Copyright (C) 2018-2019 HuntLabs
5 *
6 * Website: https://www.huntlabs.net/
7 *
8 * Licensed under the Apache-2.0 License.
9 *
10 */11 12 modulehunt.redis.commands.BasicCommands;
13 14 importhunt.redis.DebugParams;
15 importhunt.Long;
16 17 interfaceBasicCommands {
18 19 /**
20 * This command is often used to test if a connection is still alive, or to measure latency.
21 *
22 * @return PONG
23 */24 stringping();
25 26 /**
27 * Ask the server to close the connection. The connection is closed as soon as all pending replies have been written to the client.
28 * @return OK
29 */30 stringquit();
31 32 /**
33 * Delete all the keys of the currently selected DB. This command never fails.
34 The time-complexity for this operation is O(N), N being the number of keys in the database.
35 * @return OK
36 */37 stringflushDB();
38 39 /**
40 * Return the number of keys in the currently-selected database.
41 * @return the number of key in the currently-selected database.
42 */43 LongdbSize();
44 45 /**
46 * Select the DB with having the specified zero-based numeric index.
47 * @param index the index
48 * @return a simple string reply OK
49 */50 stringselect(intindex);
51 52 /**
53 * This command swaps two Redis databases, so that immediately all the clients connected to a
54 * given database will see the data of the other database, and the other way around.
55 * @param index1
56 * @param index2
57 * @return Simple string reply: OK if SWAPDB was executed correctly.
58 */59 stringswapDB(intindex1, intindex2);
60 61 /**
62 * Delete all the keys of all the existing databases, not just the currently selected one.
63 * @return a simple string reply (OK)
64 */65 stringflushAll();
66 67 /**
68 * Request for authentication in a password-protected Redis server. Redis can be instructed to require a password
69 before allowing clients to execute commands. This is done using the requirepass directive in the configuration file.
70 If password matches the password in the configuration file, the server replies with the OK status code and starts
71 accepting commands. Otherwise, an error is returned and the clients needs to try a new password.
72 * @param password
73 * @return the result of the auth
74 */75 stringauth(stringpassword);
76 77 /**
78 * The SAVE commands performs a synchronous save of the dataset producing a point in time snapshot of
79 * all the data inside the Redis instance, in the form of an RDB file.
80 * You almost never want to call SAVE in production environments where it will block all the other clients.
81 * Instead usually BGSAVE is used. However in case of issues preventing Redis to create the background
82 * saving child (for instance errors in the fork(2) system call), the SAVE command can be a good last
83 * resort to perform the dump of the latest dataset.
84 * @return result of the save
85 */86 stringsave();
87 88 /**
89 * Save the DB in background. The OK code is immediately returned. Redis forks, the parent continues
90 * to serve the clients, the child saves the DB on disk then exits. A client may be able to check if
91 * the operation succeeded using the LASTSAVE command.
92 * @return ok
93 */94 stringbgsave();
95 96 /**
97 * Instruct Redis to start an Append Only File rewrite process. The rewrite will create a small optimized
98 * version of the current Append Only File If BGREWRITEAOF fails, no data gets lost as the old AOF will
99 * be untouched. The rewrite will be only triggered by Redis if there is not already a background process
100 * doing persistence. Specifically: If a Redis child is creating a snapshot on disk, the AOF rewrite is
101 * scheduled but not started until the saving child producing the RDB file terminates. In this case the
102 * BGREWRITEAOF will still return an OK code, but with an appropriate message. You can check if an AOF
103 * rewrite is scheduled looking at the INFO command as of Redis 2.6.
104 If an AOF rewrite is already in progress the command returns an error and no AOF rewrite will be scheduled for a later time.
105 Since Redis 2.4 the AOF rewrite is automatically triggered by Redis, however the BGREWRITEAOF command can be used to trigger a rewrite at any time.
106 * @return the response of the command
107 */108 stringbgrewriteaof();
109 110 /**
111 * Return the UNIX TIME of the last DB save executed with success.
112 * @return the unix latest save
113 */114 Longlastsave();
115 116 /**
117 * Stop all the client. Perform a SAVE (if one save point is configured).
118 * Flush the append only file if AOF is enabled
119 * quit the server
120 * @return only in case of error.
121 */122 stringshutdown();
123 124 /**
125 * The INFO command returns information and statistics about the server in a format that is simple to parse by computers and easy to read by humans.
126 * @return information on the server
127 */128 stringinfo();
129 130 /**
131 * The INFO command returns information and statistics about the server in a format that is simple to parse by computers and easy to read by humans.
132 * @param section (all: Return all sections, default: Return only the default set of sections, server: General information about the Redis server, clients: Client connections section, memory: Memory consumption related information, persistence: RDB and AOF related information, stats: General statistics, replication: Master/slave replication information, cpu: CPU consumption statistics, commandstats: Redis command statistics, cluster: Redis Cluster section, keyspace: Database related statistics)
133 * @return
134 */135 stringinfo(stringsection);
136 137 /**
138 * The SLAVEOF command can change the replication settings of a slave on the fly. In the proper form SLAVEOF hostname port will make the server a slave of another server listening at the specified hostname and port.
139 * If a server is already a slave of some master, SLAVEOF hostname port will stop the replication against the old server and start the synchronization against the new one, discarding the old dataset.
140 * @param host, listening at the specified hostname
141 * @param port, server listening at the specified port
142 * @return result of the command.
143 */144 stringslaveof(stringhost, intport);
145 146 /**
147 * SLAVEOF NO ONE will stop replication, turning the server into a MASTER, but will not discard the replication. So, if the old master stops working, it is possible to turn the slave into a master and set the application to use this new master in read/write. Later when the other Redis server is fixed, it can be reconfigured to work as a slave.
148 * @return result of the command
149 */150 stringslaveofNoOne();
151 152 /**
153 * Return the index of the current database
154 * @return the int of the index database.
155 */156 intgetDB();
157 158 // string debug(DebugParams params);159 160 stringconfigResetStat();
161 162 stringconfigRewrite();
163 164 /**
165 * Blocks until all the previous write commands are successfully transferred and acknowledged by
166 * at least the specified number of replicas.
167 * If the timeout, specified in milliseconds, is reached, the command returns
168 * even if the specified number of replicas were not yet reached.
169 *
170 * @param replicas successfully transferred and acknowledged by at least the specified number of replicas
171 * @param timeout the time to block in milliseconds, a timeout of 0 means to block forever
172 * @return the number of replicas reached by all the writes performed in the context of the current connection
173 */174 LongwaitReplicas(intreplicas, longtimeout);
175 }