~ubuntu-branches/ubuntu/trusty/smuxi/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/ServiceStack/src/ServiceStack.Interfaces/Redis/IRedisClient.cs

  • Committer: Package Import Robot
  • Author(s): Mirco Bauer
  • Date: 2013-05-25 22:11:31 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20130525221131-nd2mc0kzubuwyx20
Tags: 0.8.11-1
* [22d13d5] Imported Upstream version 0.8.11
* [6d2b95a] Refreshed patches
* [89eb66e] Added ServiceStack libraries to smuxi-engine package
* [848ab10] Enable Campfire engine
* [c6dbdc7] Always build db4o for predictable build result
* [13ec489] Exclude OS X specific libraries from dh_clideps

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// http://code.google.com/p/servicestack/wiki/ServiceStackRedis
 
3
// ServiceStack.Redis: ECMA CLI Binding to the Redis key-value storage system
 
4
//
 
5
// Authors:
 
6
//   Demis Bellot (demis.bellot@gmail.com)
 
7
//
 
8
// Copyright 2010 Liquidbit Ltd.
 
9
//
 
10
// Licensed under the same terms of Redis and ServiceStack: new BSD license.
 
11
//
 
12
 
 
13
using System;
 
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;
 
20
 
 
21
namespace ServiceStack.Redis
 
22
{
 
23
        public interface IRedisClient
 
24
                : IBasicPersistenceProvider, ICacheClient
 
25
        {
 
26
                //Basic Redis Connection operations
 
27
                int Db { get; set; }
 
28
                int DbSize { get; }
 
29
                Dictionary<string, string> Info { get; }
 
30
                DateTime LastSave { get; }
 
31
                string Host { get; }
 
32
                int Port { 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; }
 
39
 
 
40
                void Save();
 
41
                void SaveAsync();
 
42
                void Shutdown();
 
43
                void RewriteAppendOnlyFileAsync();
 
44
                void FlushDb();
 
45
 
 
46
                //Basic Redis Connection Info
 
47
                string this[string key] { get; set; }
 
48
 
 
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);
 
64
 
 
65
        //store POCOs as hash
 
66
            T GetFromHash<T>(object id);
 
67
            void StoreAsHash<T>(T entity);
 
68
 
 
69
            object StoreObject(object entity);
 
70
 
 
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);
 
78
 
 
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);
 
85
 
 
86
                //Store entities without registering entity ids
 
87
                void WriteAll<TEntity>(IEnumerable<TEntity> entities);
 
88
 
 
89
                /// <summary>
 
90
                /// Returns a high-level typed client API
 
91
                /// Shorter Alias is As&lt;T&gt;();
 
92
                /// </summary>
 
93
                /// <typeparam name="T"></typeparam>
 
94
                IRedisTypedClient<T> GetTypedClient<T>();
 
95
 
 
96
                /// <summary>
 
97
                /// Returns a high-level typed client API
 
98
                /// </summary>
 
99
                /// <typeparam name="T"></typeparam>
 
100
                IRedisTypedClient<T> As<T>(); 
 
101
 
 
102
                IHasNamed<IRedisList> Lists { get; set; }
 
103
                IHasNamed<IRedisSet> Sets { get; set; }
 
104
                IHasNamed<IRedisSortedSet> SortedSets { get; set; }
 
105
                IHasNamed<IRedisHash> Hashes { get; set; }
 
106
 
 
107
                IRedisTransaction CreateTransaction();
 
108
            IRedisPipeline CreatePipeline();
 
109
 
 
110
                IDisposable AcquireLock(string key);
 
111
                IDisposable AcquireLock(string key, TimeSpan timeOut);
 
112
 
 
113
                #region Redis pubsub
 
114
 
 
115
                void Watch(params string[] keys);
 
116
                void UnWatch();
 
117
                IRedisSubscription CreateSubscription();
 
118
                int PublishMessage(string toChannel, string message);
 
119
 
 
120
                #endregion
 
121
 
 
122
 
 
123
                #region Set operations
 
124
 
 
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);
 
140
 
 
141
                #endregion
 
142
 
 
143
 
 
144
                #region List operations
 
145
 
 
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);
 
154
 
 
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);
 
166
 
 
167
                //Queue operations
 
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);
 
172
 
 
173
                //Stack operations
 
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);
 
179
 
 
180
                #endregion
 
181
 
 
182
 
 
183
                #region Sorted Set operations
 
184
 
 
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);
 
238
 
 
239
                #endregion
 
240
 
 
241
 
 
242
                #region Hash operations
 
243
 
 
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);
 
256
 
 
257
                #endregion
 
258
 
 
259
 
 
260
                #region Eval/Lua operations
 
261
 
 
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);
 
265
 
 
266
                #endregion
 
267
 
 
268
        }
 
269
}
 
 
b'\\ No newline at end of file'