2
// http://code.google.com/p/servicestack/wiki/ServiceStackRedis
3
// ServiceStack.Redis: ECMA CLI Binding to the Redis key-value storage system
6
// Demis Bellot (demis.bellot@gmail.com)
8
// Copyright 2010 Liquidbit Ltd.
10
// Licensed under the same terms of Redis and ServiceStack: new BSD license.
14
using System.Collections.Generic;
15
using ServiceStack.CacheAccess;
16
using ServiceStack.DataAccess;
17
using ServiceStack.DesignPatterns.Model;
18
using ServiceStack.Redis.Generic;
19
using ServiceStack.Redis.Pipeline;
21
namespace ServiceStack.Redis
23
public interface IRedisClient
24
: IBasicPersistenceProvider, ICacheClient
26
//Basic Redis Connection operations
29
Dictionary<string, string> Info { get; }
30
DateTime LastSave { get; }
33
int ConnectTimeout { get; set; }
34
int RetryTimeout { get; set; }
35
int RetryCount { get; set; }
36
int SendTimeout { get; set; }
37
string Password { get; set; }
38
bool HadExceptions { get; }
43
void RewriteAppendOnlyFileAsync();
46
//Basic Redis Connection Info
47
string this[string key] { get; set; }
49
List<string> GetAllKeys();
50
void SetEntry(string key, string value);
51
void SetEntry(string key, string value, TimeSpan expireIn);
52
bool SetEntryIfNotExists(string key, string value);
53
void SetAll(IEnumerable<string> keys, IEnumerable<string> values);
54
void SetAll(Dictionary<string, string> map);
55
string GetValue(string key);
56
string GetAndSetEntry(string key, string value);
57
List<string> GetValues(List<string> keys);
58
List<T> GetValues<T>(List<string> keys);
59
Dictionary<string, string> GetValuesMap(List<string> keys);
60
Dictionary<string, T> GetValuesMap<T>(List<string> keys);
61
int AppendToValue(string key, string value);
62
void RenameKey(string fromName, string toName);
63
string GetSubstring(string key, int fromIndex, int toIndex);
66
T GetFromHash<T>(object id);
67
void StoreAsHash<T>(T entity);
69
object StoreObject(object entity);
71
bool ContainsKey(string key);
72
bool RemoveEntry(params string[] args);
73
long IncrementValue(string key);
74
long IncrementValueBy(string key, int count);
75
long DecrementValue(string key);
76
long DecrementValueBy(string key, int count);
77
List<string> SearchKeys(string pattern);
79
RedisKeyType GetEntryType(string key);
80
string GetRandomKey();
81
bool ExpireEntryIn(string key, TimeSpan expireIn);
82
bool ExpireEntryAt(string key, DateTime expireAt);
83
TimeSpan GetTimeToLive(string key);
84
List<string> GetSortedEntryValues(string key, int startingFrom, int endingAt);
86
//Store entities without registering entity ids
87
void WriteAll<TEntity>(IEnumerable<TEntity> entities);
90
/// Returns a high-level typed client API
91
/// Shorter Alias is As<T>();
93
/// <typeparam name="T"></typeparam>
94
IRedisTypedClient<T> GetTypedClient<T>();
97
/// Returns a high-level typed client API
99
/// <typeparam name="T"></typeparam>
100
IRedisTypedClient<T> As<T>();
102
IHasNamed<IRedisList> Lists { get; set; }
103
IHasNamed<IRedisSet> Sets { get; set; }
104
IHasNamed<IRedisSortedSet> SortedSets { get; set; }
105
IHasNamed<IRedisHash> Hashes { get; set; }
107
IRedisTransaction CreateTransaction();
108
IRedisPipeline CreatePipeline();
110
IDisposable AcquireLock(string key);
111
IDisposable AcquireLock(string key, TimeSpan timeOut);
115
void Watch(params string[] keys);
117
IRedisSubscription CreateSubscription();
118
int PublishMessage(string toChannel, string message);
123
#region Set operations
125
HashSet<string> GetAllItemsFromSet(string setId);
126
void AddItemToSet(string setId, string item);
127
void AddRangeToSet(string setId, List<string> items);
128
void RemoveItemFromSet(string setId, string item);
129
string PopItemFromSet(string setId);
130
void MoveBetweenSets(string fromSetId, string toSetId, string item);
131
int GetSetCount(string setId);
132
bool SetContainsItem(string setId, string item);
133
HashSet<string> GetIntersectFromSets(params string[] setIds);
134
void StoreIntersectFromSets(string intoSetId, params string[] setIds);
135
HashSet<string> GetUnionFromSets(params string[] setIds);
136
void StoreUnionFromSets(string intoSetId, params string[] setIds);
137
HashSet<string> GetDifferencesFromSet(string fromSetId, params string[] withSetIds);
138
void StoreDifferencesFromSet(string intoSetId, string fromSetId, params string[] withSetIds);
139
string GetRandomItemFromSet(string setId);
144
#region List operations
146
List<string> GetAllItemsFromList(string listId);
147
List<string> GetRangeFromList(string listId, int startingFrom, int endingAt);
148
List<string> GetRangeFromSortedList(string listId, int startingFrom, int endingAt);
149
List<string> GetSortedItemsFromList(string listId, SortOptions sortOptions);
150
void AddItemToList(string listId, string value);
151
void AddRangeToList(string listId, List<string> values);
152
void PrependItemToList(string listId, string value);
153
void PrependRangeToList(string listId, List<string> values);
155
void RemoveAllFromList(string listId);
156
string RemoveStartFromList(string listId);
157
string BlockingRemoveStartFromList(string listId, TimeSpan? timeOut);
158
ItemRef BlockingRemoveStartFromLists(string []listIds, TimeSpan? timeOut);
159
string RemoveEndFromList(string listId);
160
void TrimList(string listId, int keepStartingFrom, int keepEndingAt);
161
int RemoveItemFromList(string listId, string value);
162
int RemoveItemFromList(string listId, string value, int noOfMatches);
163
int GetListCount(string listId);
164
string GetItemFromList(string listId, int listIndex);
165
void SetItemInList(string listId, int listIndex, string value);
168
void EnqueueItemOnList(string listId, string value);
169
string DequeueItemFromList(string listId);
170
string BlockingDequeueItemFromList(string listId, TimeSpan? timeOut);
171
ItemRef BlockingDequeueItemFromLists(string []listIds, TimeSpan? timeOut);
174
void PushItemToList(string listId, string value);
175
string PopItemFromList(string listId);
176
string BlockingPopItemFromList(string listId, TimeSpan? timeOut);
177
ItemRef BlockingPopItemFromLists(string []listIds, TimeSpan? timeOut);
178
string PopAndPushItemBetweenLists(string fromListId, string toListId);
183
#region Sorted Set operations
185
bool AddItemToSortedSet(string setId, string value);
186
bool AddItemToSortedSet(string setId, string value, double score);
187
bool AddRangeToSortedSet(string setId, List<string> values, double score);
188
bool AddRangeToSortedSet(string setId, List<string> values, long score);
189
bool RemoveItemFromSortedSet(string setId, string value);
190
string PopItemWithLowestScoreFromSortedSet(string setId);
191
string PopItemWithHighestScoreFromSortedSet(string setId);
192
bool SortedSetContainsItem(string setId, string value);
193
double IncrementItemInSortedSet(string setId, string value, double incrementBy);
194
double IncrementItemInSortedSet(string setId, string value, long incrementBy);
195
int GetItemIndexInSortedSet(string setId, string value);
196
int GetItemIndexInSortedSetDesc(string setId, string value);
197
List<string> GetAllItemsFromSortedSet(string setId);
198
List<string> GetAllItemsFromSortedSetDesc(string setId);
199
List<string> GetRangeFromSortedSet(string setId, int fromRank, int toRank);
200
List<string> GetRangeFromSortedSetDesc(string setId, int fromRank, int toRank);
201
IDictionary<string, double> GetAllWithScoresFromSortedSet(string setId);
202
IDictionary<string, double> GetRangeWithScoresFromSortedSet(string setId, int fromRank, int toRank);
203
IDictionary<string, double> GetRangeWithScoresFromSortedSetDesc(string setId, int fromRank, int toRank);
204
List<string> GetRangeFromSortedSetByLowestScore(string setId, string fromStringScore, string toStringScore);
205
List<string> GetRangeFromSortedSetByLowestScore(string setId, string fromStringScore, string toStringScore, int? skip, int? take);
206
List<string> GetRangeFromSortedSetByLowestScore(string setId, double fromScore, double toScore);
207
List<string> GetRangeFromSortedSetByLowestScore(string setId, long fromScore, long toScore);
208
List<string> GetRangeFromSortedSetByLowestScore(string setId, double fromScore, double toScore, int? skip, int? take);
209
List<string> GetRangeFromSortedSetByLowestScore(string setId, long fromScore, long toScore, int? skip, int? take);
210
IDictionary<string, double> GetRangeWithScoresFromSortedSetByLowestScore(string setId, string fromStringScore, string toStringScore);
211
IDictionary<string, double> GetRangeWithScoresFromSortedSetByLowestScore(string setId, string fromStringScore, string toStringScore, int? skip, int? take);
212
IDictionary<string, double> GetRangeWithScoresFromSortedSetByLowestScore(string setId, double fromScore, double toScore);
213
IDictionary<string, double> GetRangeWithScoresFromSortedSetByLowestScore(string setId, long fromScore, long toScore);
214
IDictionary<string, double> GetRangeWithScoresFromSortedSetByLowestScore(string setId, double fromScore, double toScore, int? skip, int? take);
215
IDictionary<string, double> GetRangeWithScoresFromSortedSetByLowestScore(string setId, long fromScore, long toScore, int? skip, int? take);
216
List<string> GetRangeFromSortedSetByHighestScore(string setId, string fromStringScore, string toStringScore);
217
List<string> GetRangeFromSortedSetByHighestScore(string setId, string fromStringScore, string toStringScore, int? skip, int? take);
218
List<string> GetRangeFromSortedSetByHighestScore(string setId, double fromScore, double toScore);
219
List<string> GetRangeFromSortedSetByHighestScore(string setId, long fromScore, long toScore);
220
List<string> GetRangeFromSortedSetByHighestScore(string setId, double fromScore, double toScore, int? skip, int? take);
221
List<string> GetRangeFromSortedSetByHighestScore(string setId, long fromScore, long toScore, int? skip, int? take);
222
IDictionary<string, double> GetRangeWithScoresFromSortedSetByHighestScore(string setId, string fromStringScore, string toStringScore);
223
IDictionary<string, double> GetRangeWithScoresFromSortedSetByHighestScore(string setId, string fromStringScore, string toStringScore, int? skip, int? take);
224
IDictionary<string, double> GetRangeWithScoresFromSortedSetByHighestScore(string setId, double fromScore, double toScore);
225
IDictionary<string, double> GetRangeWithScoresFromSortedSetByHighestScore(string setId, long fromScore, long toScore);
226
IDictionary<string, double> GetRangeWithScoresFromSortedSetByHighestScore(string setId, double fromScore, double toScore, int? skip, int? take);
227
IDictionary<string, double> GetRangeWithScoresFromSortedSetByHighestScore(string setId, long fromScore, long toScore, int? skip, int? take);
228
int RemoveRangeFromSortedSet(string setId, int minRank, int maxRank);
229
int RemoveRangeFromSortedSetByScore(string setId, double fromScore, double toScore);
230
int RemoveRangeFromSortedSetByScore(string setId, long fromScore, long toScore);
231
int GetSortedSetCount(string setId);
232
int GetSortedSetCount(string setId, string fromStringScore, string toStringScore);
233
int GetSortedSetCount(string setId, long fromScore, long toScore);
234
int GetSortedSetCount(string setId, double fromScore, double toScore);
235
double GetItemScoreInSortedSet(string setId, string value);
236
int StoreIntersectFromSortedSets(string intoSetId, params string[] setIds);
237
int StoreUnionFromSortedSets(string intoSetId, params string[] setIds);
242
#region Hash operations
244
bool HashContainsEntry(string hashId, string key);
245
bool SetEntryInHash(string hashId, string key, string value);
246
bool SetEntryInHashIfNotExists(string hashId, string key, string value);
247
void SetRangeInHash(string hashId, IEnumerable<KeyValuePair<string, string>> keyValuePairs);
248
int IncrementValueInHash(string hashId, string key, int incrementBy);
249
string GetValueFromHash(string hashId, string key);
250
List<string> GetValuesFromHash(string hashId, params string[] keys);
251
bool RemoveEntryFromHash(string hashId, string key);
252
int GetHashCount(string hashId);
253
List<string> GetHashKeys(string hashId);
254
List<string> GetHashValues(string hashId);
255
Dictionary<string, string> GetAllEntriesFromHash(string hashId);
260
#region Eval/Lua operations
262
string GetEvalStr(string body, int numOfArgs, params string[] args);
263
int GetEvalInt(string body, int numOfArgs, params string[] args);
264
List<string> GetEvalMultiData(string body, int numOfArgs, params string[] args);
b'\\ No newline at end of file'