Skip to content

Commit 4efa9af

Browse files
committed
Updated README with new IRedisClient interface
1 parent bbcbf93 commit 4efa9af

File tree

1 file changed

+191
-82
lines changed

1 file changed

+191
-82
lines changed

README.md

Lines changed: 191 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -13,122 +13,231 @@ This is the Redis Client interface used to connect, send commands and manager th
1313
```Delphi
1414
IRedisClient = interface
1515
['{566C20FF-7D9F-4DAC-9B0E-A8AA7D29B0B4}']
16-
function &SET(const AKey, AValue: string): boolean; overload;
17-
function &SET(const AKey, AValue: TBytes): boolean; overload;
18-
function &SET(const AKey: string; AValue: TBytes): boolean; overload;
19-
function &SET(const AKey: string; AValue: TBytes; ASecsExpire: UInt64): boolean; overload;
20-
function &SET(const AKey: string; AValue: string; ASecsExpire: UInt64): boolean; overload;
21-
function SETNX(const AKey, AValue: string): boolean; overload;
22-
function SETNX(const AKey, AValue: TBytes): boolean; overload;
23-
function GET(const AKey: string; out AValue: string): boolean; overload;
24-
function GET(const AKey: TBytes; out AValue: TBytes): boolean; overload;
25-
function GET(const AKey: string; out AValue: TBytes): boolean; overload;
26-
function DEL(const AKeys: array of string): Integer;
27-
function TTL(const AKey: string): Integer;
28-
function EXISTS(const AKey: string): boolean;
29-
function MSET(const AKeysValues: array of string): boolean;
30-
function KEYS(const AKeyPattern: string): TArray<string>;
31-
function INCR(const AKey: string): NativeInt;
32-
function DECR(const AKey: string): NativeInt;
33-
function EXPIRE(const AKey: string; AExpireInSecond: UInt32): boolean;
16+
17+
function &SET(const aKey, aValue: string): boolean; overload;
18+
19+
function &SET(const aKey, aValue: TBytes): boolean; overload;
20+
function &SET(const aKey: string; aValue: TBytes): boolean; overload;
21+
function &SET(const aKey: string; aValue: TBytes; aSecsExpire: UInt64)
22+
: boolean; overload;
23+
function &SET(const aKey: string; aValue: string; aSecsExpire: UInt64)
24+
: boolean; overload;
25+
function SETNX(const aKey, aValue: string): boolean; overload;
26+
function SETNX(const aKey, aValue: TBytes): boolean; overload;
27+
function GET(const aKey: string; out aValue: string): boolean; overload;
28+
deprecated 'Use GET(aKey: string): TRedisString';
29+
function GET(const aKey: string): TRedisString; overload;
30+
function GET_AsBytes(const aKey: string): TRedisBytes;
31+
function GET(const aKey: TBytes; out aValue: TBytes): boolean; overload;
32+
deprecated 'Use GET(aKey: string): TRedisString';
33+
function GET(const aKey: string; out aValue: TBytes): boolean; overload;
34+
deprecated 'Use GET(aKey: string): TRedisString';
35+
function DEL(const aKeys: array of string): Integer;
36+
function TTL(const aKey: string): Integer;
37+
function EXISTS(const aKey: string): boolean;
38+
function MSET(const aKeysValues: array of string): boolean;
39+
function KEYS(const AKeyPattern: string): TRedisArray;
40+
function INCR(const aKey: string): Int64;
41+
function DECR(const aKey: string): Int64;
42+
function EXPIRE(const aKey: string; aExpireInSecond: UInt32): boolean;
43+
function PERSIST(const aKey: string): boolean;
44+
function RANDOMKEY: TRedisString;
45+
function RENAME(const aKey, aNewKey: string): boolean;
46+
function RENAMENX(const aKey, aNewKey: string): boolean;
3447
3548
// strings functions
36-
function APPEND(const AKey, AValue: TBytes): UInt64; overload;
37-
function APPEND(const AKey, AValue: string): UInt64; overload;
38-
function STRLEN(const AKey: string): UInt64;
39-
function GETRANGE(const AKey: string; const AStart, AEnd: NativeInt): string;
40-
function SETRANGE(const AKey: string; const AOffset: NativeInt; const AValue: string)
41-
: NativeInt;
49+
function APPEND(const aKey, aValue: TBytes): UInt64; overload;
50+
function APPEND(const aKey, aValue: string): UInt64; overload;
51+
function STRLEN(const aKey: string): UInt64;
52+
function GETRANGE(const aKey: string;
53+
const aStart, aEnd: NativeInt): string;
54+
function SETRANGE(const aKey: string; const aOffset: NativeInt;
55+
const aValue: string): NativeInt;
4256
4357
// hash
44-
function HSET(const AKey, aField: string; AValue: string): Integer; overload;
45-
procedure HMSET(const AKey: string; aFields: TArray<string>; AValues: TArray<string>);
46-
function HMGET(const AKey: string; aFields: TArray<string>): TArray<string>;
47-
function HSET(const AKey, aField: string; AValue: TBytes): Integer; overload;
48-
function HGET(const AKey, aField: string; out AValue: TBytes): boolean; overload;
49-
function HGET(const AKey, aField: string; out AValue: string): boolean; overload;
50-
function HDEL(const AKey: string; aFields: TArray<string>): Integer;
58+
function HSET(const aKey, aField: string; aValue: string): Integer;
59+
overload;
60+
procedure HMSET(const aKey: string; aFields: TArray<string>;
61+
aValues: TArray<string>); overload;
62+
procedure HMSET(const aKey: string; aFields: TArray<string>;
63+
aValues: TArray<TBytes>); overload;
64+
function HSET(const aKey, aField: string; aValue: TBytes): Integer;
65+
overload;
66+
function HGET(const aKey, aField: string; out aValue: TBytes)
67+
: boolean; overload;
68+
function HGET(const aKey, aField: string; out aValue: string)
69+
: boolean; overload;
70+
function HGET_AsBytes(const aKey, aField: string): TRedisBytes;
71+
function HGET(const aKey, aField: string): TRedisString; overload;
72+
function HMGET(const aKey: string; aFields: TArray<string>)
73+
: TRedisArray; overload;
74+
function HDEL(const aKey: string; aFields: TArray<string>): Integer;
75+
function HKEYS(const aKey: string): TRedisArray;
76+
function HVALS(const aKey: string): TRedisArray;
77+
function HEXISTS(const aKey, aField: string): Boolean;
78+
function HLEN(const aKey: string): Integer;
79+
function HINCRBY(const aKey, aField: string; const AIncrement: NativeInt): Integer;
80+
function HINCRBYFLOAT(const aKey, aField: string; const AIncrement: Double): Double;
5181
5282
// lists
53-
function RPUSH(const AListKey: string; AValues: array of string): Integer;
54-
function RPUSHX(const AListKey: string; AValues: array of string): Integer;
55-
function RPOP(const AListKey: string; var Value: string): boolean;
56-
function LPUSH(const AListKey: string; AValues: array of string): Integer;
57-
function LPUSHX(const AListKey: string; AValues: array of string): Integer;
58-
function LPOP(const AListKey: string; out Value: string): boolean;
59-
function LLEN(const AListKey: string): Integer;
60-
procedure LTRIM(const AListKey: string; const AIndexStart, AIndexStop: Integer);
61-
function LRANGE(const AListKey: string; IndexStart, IndexStop: Integer)
62-
: TArray<string>;
63-
function RPOPLPUSH(const ARightListKey, ALeftListKey: string;
64-
var APoppedAndPushedElement: string): boolean; overload;
65-
function BRPOPLPUSH(const ARightListKey, ALeftListKey: string;
66-
var APoppedAndPushedElement: string; ATimeout: Int32): boolean; overload;
67-
function BLPOP(const AKeys: array of string; const ATimeout: Int32;
68-
out Value: TArray<string>): boolean;
69-
function BRPOP(const AKeys: array of string; const ATimeout: Int32;
70-
out Value: TArray<string>): boolean;
71-
function LREM(const AListKey: string; const ACount: Integer;
72-
const AValue: string): Integer;
83+
function RPUSH(const aListKey: string; aValues: array of string): Integer;
84+
function RPUSHX(const aListKey: string; aValues: array of string): Integer;
85+
function RPOP(const aListKey: string; var Value: string): boolean; overload;
86+
function RPOP(const aListKey: string): TRedisString; overload;
87+
function LPUSH(const aListKey: string; aValues: array of string): Integer;
88+
function LPUSHX(const aListKey: string; aValues: array of string): Integer;
89+
function LPOP(const aListKey: string; out Value: string): boolean; overload;
90+
function LPOP(const aListKey: string): TRedisString; overload;
91+
function LLEN(const aListKey: string): Integer;
92+
procedure LTRIM(const aListKey: string;
93+
const aIndexStart, aIndexStop: Integer);
94+
function LRANGE(const aListKey: string; aIndexStart, aIndexStop: Integer)
95+
: TRedisArray;
96+
function RPOPLPUSH(const aRightListKey, aLeftListKey: string;
97+
var aPoppedAndPushedElement: string): boolean; overload;
98+
function BRPOPLPUSH(const aRightListKey, aLeftListKey: string;
99+
var aPoppedAndPushedElement: string; aTimeout: Int32): boolean; overload;
100+
function BLPOP(const aKeys: array of string; const aTimeout: Int32;
101+
out Value: TArray<string>): boolean; overload;
102+
deprecated 'Use BLPOP: TRedisArray';
103+
function BLPOP(const aKeys: array of string; const aTimeout: Int32)
104+
: TRedisArray; overload;
105+
function BRPOP(const aKeys: array of string; const aTimeout: Int32;
106+
out Value: TArray<string>): boolean; overload;
107+
deprecated 'Use BRPOP: TRedisArray';
108+
function BRPOP(const aKeys: array of string; const aTimeout: Int32)
109+
: TRedisArray; overload;
110+
function LREM(const aListKey: string; const aCount: Integer;
111+
const aValue: string): Integer;
73112
74113
// sets
75-
function SADD(const AKey, AValue: TBytes): Integer; overload;
76-
function SADD(const AKey, AValue: string): Integer; overload;
77-
function SREM(const AKey, AValue: TBytes): Integer; overload;
78-
function SREM(const AKey, AValue: string): Integer; overload;
79-
function SMEMBERS(const AKey: string): TArray<string>;
80-
function SCARD(const AKey: string): Integer;
114+
function SADD(const aKey, aValue: TBytes): Integer; overload;
115+
function SADD(const aKey, aValue: string): Integer; overload;
116+
function SDIFF(const aKeys: array of string): TRedisArray;
117+
function SREM(const aKey, aValue: TBytes): Integer; overload;
118+
function SREM(const aKey, aValue: string): Integer; overload;
119+
function SISMEMBER(const aKey, aValue: TBytes): Integer; overload;
120+
function SISMEMBER(const aKey, aValue: string): Integer; overload;
121+
function SMEMBERS(const aKey: string): TRedisArray;
122+
function SCARD(const aKey: string): Integer;
123+
function SUNION(const aKeys: array of string): TRedisArray;
124+
function SUNIONSTORE(const aDestination: String; const aKeys: array of string): Integer;
81125
82126
// ordered sets
83-
function ZADD(const AKey: string; const AScore: Int64; const AMember: string): Integer;
84-
function ZREM(const AKey: string; const AMember: string): Integer;
85-
function ZCARD(const AKey: string): Integer;
86-
function ZCOUNT(const AKey: string; const AMin, AMax: Int64): Integer;
87-
function ZRANK(const AKey: string; const AMember: string; out ARank: Int64): boolean;
88-
function ZRANGE(const AKey: string; const AStart, AStop: Int64): TArray<string>;
89-
function ZRANGEWithScore(const AKey: string; const AStart, AStop: Int64): TArray<string>;
90-
function ZINCRBY(const AKey: string; const AIncrement: Int64; const AMember: string): string;
127+
function ZADD(const aKey: string; const AScore: Int64;
128+
const AMember: string): Integer;
129+
function ZREM(const aKey: string; const AMember: string): Integer;
130+
function ZCARD(const aKey: string): Integer;
131+
function ZCOUNT(const aKey: string; const AMin, AMax: Int64): Integer;
132+
function ZRANK(const aKey: string; const AMember: string;
133+
out ARank: Int64): boolean;
134+
function ZRANGE(const aKey: string; const aStart, AStop: Int64;
135+
const aScores: TRedisScoreMode = TRedisScoreMode.WithoutScores): TRedisArray;
136+
function ZREVRANGE(const aKey: string; const aStart, AStop: Int64;
137+
const aScoreMode: TRedisScoreMode = TRedisScoreMode.WithoutScores): TRedisArray;
138+
// function ZRANGEWithScore(const aKey: string; const aStart, AStop: Int64)
139+
// : TRedisArray;
140+
function ZINCRBY(const aKey: string; const AIncrement: Int64;
141+
const AMember: string): string;
142+
function ZUNIONSTORE(const aDestination: string;
143+
const aNumKeys: NativeInt; const aKeys: array of string): Int64; overload;
144+
function ZUNIONSTORE(const aDestination: string;
145+
const aNumKeys: NativeInt; const aKeys: array of string; const aWeights: array of Integer): Int64; overload;
146+
function ZUNIONSTORE(const aDestination: string;
147+
const aNumKeys: NativeInt; const aKeys: array of string; const aWeights: array of Integer; const aAggregate: TRedisAggregate): Int64; overload;
148+
149+
// geo
150+
/// <summary>
151+
/// GEOADD (Redis 3.2+)
152+
/// </summary>
153+
function GEOADD(const Key: string; const Latitude, Longitude: Extended;
154+
Member: string): Integer;
155+
/// <summary>
156+
/// GEODIST (Redis 3.2+)
157+
/// </summary>
158+
function GEODIST(const Key: string; const Member1, Member2: string;
159+
const &Unit: TRedisGeoUnit = TRedisGeoUnit.Meters): TRedisString;
160+
161+
/// <summary>
162+
/// GEOHASH (Redis 3.2+)
163+
/// </summary>
164+
function GEOHASH(const Key: string; const Members: array of string)
165+
: TRedisArray;
166+
167+
/// <summary>
168+
/// GEOPOS (Redis 3.2+)
169+
/// </summary>
170+
function GEOPOS(const Key: string; const Members: array of string)
171+
: TRedisMatrix;
172+
173+
/// <summary>
174+
/// GEORADIUS (Redis 3.2+)
175+
/// </summary>
176+
function GEORADIUS(const Key: string; const Longitude, Latitude: Extended;
177+
const Radius: Extended; const &Unit: TRedisGeoUnit = TRedisGeoUnit.Meters;
178+
const Sorting: TRedisSorting = TRedisSorting.None;
179+
const Count: Int64 = -1): TRedisArray;
180+
181+
/// <summary>
182+
/// GEORADIUS (Redis 3.2+)
183+
/// </summary>
184+
function GEORADIUS_WITHDIST(const Key: string;
185+
const Longitude, Latitude: Extended; const Radius: Extended;
186+
const &Unit: TRedisGeoUnit = TRedisGeoUnit.Meters;
187+
const Sorting: TRedisSorting = TRedisSorting.None;
188+
const Count: Int64 = -1): TRedisMatrix;
91189
92190
// lua scripts
93-
function EVAL(const AScript: string; AKeys: array of string; AValues: array of string): Integer;
191+
function EVAL(const aScript: string; aKeys: array of string;
192+
aValues: array of string): Integer;
94193
95194
// system
96195
procedure FLUSHDB;
97-
procedure SELECT(const ADBIndex: Integer);
196+
procedure FLUSHALL;
197+
procedure SELECT(const aDBIndex: Integer);
98198
procedure AUTH(const aPassword: string);
199+
function MOVE(const aKey: string; const aDB: Byte): boolean;
99200
100201
// raw execute
101-
function ExecuteAndGetArray(const RedisCommand: IRedisCommand)
102-
: TArray<string>;
103-
function ExecuteWithIntegerResult(const RedisCommand: string)
104-
: TArray<string>; overload;
202+
function ExecuteAndGetRESPArray(const RedisCommand: IRedisCommand): TRedisRESPArray;
203+
function ExecuteAndGetArray(const RedisCommand: IRedisCommand): TRedisArray;
105204
function ExecuteWithIntegerResult(const RedisCommand: IRedisCommand)
106205
: Int64; overload;
107-
function ExecuteWithStringResult(const RedisCommand: IRedisCommand): string;
108-
206+
function ExecuteWithStringResult(const RedisCommand: IRedisCommand)
207+
: TRedisString;
109208
// pubsub
110209
procedure SUBSCRIBE(const AChannels: array of string;
111-
ACallback: TProc<string, string>;
112-
ATimeoutCallback: TRedisTimeoutCallback = nil);
113-
function PUBLISH(const AChannel: string; AMessage: string): Integer;
114-
210+
aCallback: TProc<string, string>;
211+
aContinueOnTimeoutCallback: TRedisTimeoutCallback = nil;
212+
aAfterSubscribe: TRedisAction = nil);
213+
function PUBLISH(const aChannel: string; aMessage: string): Integer;
115214
// transactions
116-
function MULTI(ARedisTansactionProc: TRedisTransactionProc): TArray<string>; overload;
215+
function MULTI(aRedisTansactionProc: TRedisTransactionProc)
216+
: TRedisArray; overload;
117217
procedure MULTI; overload;
118-
function EXEC: TArray<string>;
119-
procedure WATCH(const AKeys: array of string);
218+
function EXEC: TRedisArray;
219+
procedure WATCH(const aKeys: array of string);
120220
121221
procedure DISCARD;
222+
223+
{$REGION STREAMS}
224+
function XADD(const aStreamName: String; const MaxLength: UInt64;
225+
const MaxLengthType: TRedisMaxLengthType; const Keys,
226+
Values: array of string; const ID: UInt64 = 0): String; overload;
227+
function XADD(const aStreamName: String; const Keys,
228+
Values: array of string; const ID: UInt64 = 0): String; overload;
229+
{$ENDREGION}
230+
122231
// non sys
123-
function Tokenize(const ARedisCommand: string): TArray<string>;
232+
function Tokenize(const aRedisCommand: string): TArray<string>;
233+
procedure Connect;
124234
procedure Disconnect;
125235
function InTransaction: boolean;
126236
// client
127237
procedure ClientSetName(const ClientName: string);
128238
procedure SetCommandTimeout(const Timeout: Int32);
129239
function Clone: IRedisClient;
130240
end;
131-
132241
```
133242

134243
Delphi Redis Client is not tied to a specific TCP/IP library. Currently it uses INDY but you can implement the IRedisNetLibAdapter and wrap whatever library you like.

0 commit comments

Comments
 (0)