|
| 1 | +/* |
| 2 | + * Copyright 2017 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.data.redis.connection; |
| 17 | + |
| 18 | +import reactor.core.publisher.Flux; |
| 19 | +import reactor.core.publisher.Mono; |
| 20 | + |
| 21 | +import java.util.List; |
| 22 | +import java.util.Properties; |
| 23 | + |
| 24 | +import org.springframework.data.redis.core.types.RedisClientInfo; |
| 25 | + |
| 26 | +/** |
| 27 | + * Redis Server commands executed using reactive infrastructure. |
| 28 | + * |
| 29 | + * @author Mark Paluch |
| 30 | + * @since 2.0 |
| 31 | + */ |
| 32 | +public interface ReactiveServerCommands { |
| 33 | + |
| 34 | + /** |
| 35 | + * Start an {@literal Append Only File} rewrite process on server. |
| 36 | + * |
| 37 | + * @see <a href="http://redis.io/commands/bgrewriteaof">Redis Documentation: BGREWRITEAOF</a> |
| 38 | + */ |
| 39 | + Mono<String> bgReWriteAof(); |
| 40 | + |
| 41 | + /** |
| 42 | + * Start background saving of db on server. |
| 43 | + * |
| 44 | + * @see <a href="http://redis.io/commands/bgsave">Redis Documentation: BGSAVE</a> |
| 45 | + */ |
| 46 | + Mono<String> bgSave(); |
| 47 | + |
| 48 | + /** |
| 49 | + * Get time of last {@link #bgSave()} operation in seconds. |
| 50 | + * |
| 51 | + * @return |
| 52 | + * @see <a href="http://redis.io/commands/lastsave">Redis Documentation: LASTSAVE</a> |
| 53 | + */ |
| 54 | + Mono<Long> lastSave(); |
| 55 | + |
| 56 | + /** |
| 57 | + * Synchronous save current db snapshot on server. |
| 58 | + * |
| 59 | + * @see <a href="http://redis.io/commands/save">Redis Documentation: SAVE</a> |
| 60 | + */ |
| 61 | + Mono<String> save(); |
| 62 | + |
| 63 | + /** |
| 64 | + * Get the total number of available keys in currently selected database. |
| 65 | + * |
| 66 | + * @return |
| 67 | + * @see <a href="http://redis.io/commands/dbsize">Redis Documentation: DBSIZE</a> |
| 68 | + */ |
| 69 | + Mono<Long> dbSize(); |
| 70 | + |
| 71 | + /** |
| 72 | + * Delete all keys of the currently selected database. |
| 73 | + * |
| 74 | + * @see <a href="http://redis.io/commands/flushdb">Redis Documentation: FLUSHDB</a> |
| 75 | + */ |
| 76 | + Mono<String> flushDb(); |
| 77 | + |
| 78 | + /** |
| 79 | + * Delete all <b>all keys</b> from <b>all databases</b>. |
| 80 | + * |
| 81 | + * @see <a href="http://redis.io/commands/flushall">Redis Documentation: FLUSHALL</a> |
| 82 | + */ |
| 83 | + Mono<String> flushAll(); |
| 84 | + |
| 85 | + /** |
| 86 | + * Load {@literal default} server information like |
| 87 | + * <ul> |
| 88 | + * <li>memory</li> |
| 89 | + * <li>cpu utilization</li> |
| 90 | + * <li>replication</li> |
| 91 | + * </ul> |
| 92 | + * <p> |
| 93 | + * |
| 94 | + * @return |
| 95 | + * @see <a href="http://redis.io/commands/info">Redis Documentation: INFO</a> |
| 96 | + */ |
| 97 | + Mono<Properties> info(); |
| 98 | + |
| 99 | + /** |
| 100 | + * Load server information for given {@code selection}. |
| 101 | + * |
| 102 | + * @param section |
| 103 | + * @return |
| 104 | + * @see <a href="http://redis.io/commands/info">Redis Documentation: INFO</a> |
| 105 | + */ |
| 106 | + Mono<Properties> info(String section); |
| 107 | + |
| 108 | + /** |
| 109 | + * Load configuration parameters for given {@code pattern} from server. |
| 110 | + * |
| 111 | + * @param pattern |
| 112 | + * @return |
| 113 | + * @see <a href="http://redis.io/commands/config-get">Redis Documentation: CONFIG GET</a> |
| 114 | + */ |
| 115 | + Mono<Properties> getConfig(String pattern); |
| 116 | + |
| 117 | + /** |
| 118 | + * Set server configuration for {@code param} to {@code value}. |
| 119 | + * |
| 120 | + * @param param |
| 121 | + * @param value |
| 122 | + * @see <a href="http://redis.io/commands/config-set">Redis Documentation: CONFIG SET</a> |
| 123 | + */ |
| 124 | + Mono<String> setConfig(String param, String value); |
| 125 | + |
| 126 | + /** |
| 127 | + * Reset statistic counters on server. <br> |
| 128 | + * Counters can be retrieved using {@link #info()}. |
| 129 | + * |
| 130 | + * @see <a href="http://redis.io/commands/config-resetstat">Redis Documentation: CONFIG RESETSTAT</a> |
| 131 | + */ |
| 132 | + Mono<String> resetConfigStats(); |
| 133 | + |
| 134 | + /** |
| 135 | + * Request server timestamp using {@code TIME} command. |
| 136 | + * |
| 137 | + * @return current server time in milliseconds. |
| 138 | + * @see <a href="http://redis.io/commands/time">Redis Documentation: TIME</a> |
| 139 | + */ |
| 140 | + Mono<Long> time(); |
| 141 | + |
| 142 | + /** |
| 143 | + * Closes a given client connection identified by {@literal host:port}. |
| 144 | + * |
| 145 | + * @param host of connection to close. |
| 146 | + * @param port of connection to close |
| 147 | + * @see <a href="http://redis.io/commands/client-kill">Redis Documentation: CLIENT KILL</a> |
| 148 | + */ |
| 149 | + Mono<String> killClient(String host, int port); |
| 150 | + |
| 151 | + /** |
| 152 | + * Assign given name to current connection. |
| 153 | + * |
| 154 | + * @param name |
| 155 | + * @see <a href="http://redis.io/commands/client-setname">Redis Documentation: CLIENT SETNAME</a> |
| 156 | + */ |
| 157 | + Mono<String> setClientName(String name); |
| 158 | + |
| 159 | + /** |
| 160 | + * Returns the name of the current connection. |
| 161 | + * |
| 162 | + * @see <a href="http://redis.io/commands/client-getname">Redis Documentation: CLIENT GETNAME</a> |
| 163 | + * @return |
| 164 | + */ |
| 165 | + Mono<String> getClientName(); |
| 166 | + |
| 167 | + /** |
| 168 | + * Request information and statistics about connected clients. |
| 169 | + * |
| 170 | + * @return {@link List} of {@link RedisClientInfo} objects. |
| 171 | + * @see <a href="http://redis.io/commands/client-list">Redis Documentation: CLIENT LIST</a> |
| 172 | + */ |
| 173 | + Flux<RedisClientInfo> getClientList(); |
| 174 | +} |
0 commit comments