55using Enyim . Caching ;
66using Enyim . Caching . Configuration ;
77using Enyim . Caching . Memcached ;
8- using ServiceStack . Logging ;
8+ using ILog = ServiceStack . Logging . ILog ;
9+ using LogManager = ServiceStack . Logging . LogManager ;
910
1011namespace ServiceStack . CacheAccess . Memcached
1112{
@@ -108,16 +109,6 @@ public object Get(string key, out ulong ucas)
108109 ucas = default ( ulong ) ;
109110 return null ;
110111 }
111-
112- public string GetText ( string key )
113- {
114- return Execute ( ( ) => Encoding . UTF8 . GetString ( ( byte [ ] ) client . Get ( key ) ) ) ;
115- }
116-
117- public byte [ ] GetBytes ( string key )
118- {
119- return Execute ( ( ) => ( byte [ ] ) client . Get ( key ) ) ;
120- }
121112
122113 public T Get < T > ( string key )
123114 {
@@ -142,12 +133,12 @@ public T Get<T>(string key, out ulong ucas)
142133
143134 public long Increment ( string key , uint amount )
144135 {
145- return Execute ( ( ) => client . Increment ( key , amount ) ) ;
136+ return Execute ( ( ) => ( long ) client . Increment ( key , 0 , amount ) ) ;
146137 }
147138
148139 public long Decrement ( string key , uint amount )
149140 {
150- return Execute ( ( ) => client . Decrement ( key , amount ) ) ;
141+ return Execute ( ( ) => ( long ) client . Decrement ( key , 0 , amount ) ) ;
151142 }
152143
153144 public bool Add < T > ( string key , T value )
@@ -195,41 +186,6 @@ public bool Replace<T>(string key, T value, TimeSpan expiresIn)
195186 return Execute ( ( ) => client . Store ( StoreMode . Replace , key , value , expiresIn ) ) ;
196187 }
197188
198- public bool Set ( string key , byte [ ] value )
199- {
200- return Execute ( ( ) => client . Store ( StoreMode . Set , key , value ) ) ;
201- }
202-
203- public bool Add ( string key , string value )
204- {
205- return Execute ( ( ) => client . Store ( StoreMode . Add , key , Encoding . UTF8 . GetBytes ( value ) ) ) ;
206- }
207-
208- public bool Set ( string key , string value )
209- {
210- return Execute ( ( ) => client . Store ( StoreMode . Set , key , Encoding . UTF8 . GetBytes ( value ) ) ) ;
211- }
212-
213- public bool Replace ( string key , string value )
214- {
215- return Execute ( ( ) => client . Store ( StoreMode . Replace , key , Encoding . UTF8 . GetBytes ( value ) ) ) ;
216- }
217-
218- public bool Add ( string key , string value , DateTime expiresAt )
219- {
220- return Execute ( ( ) => client . Store ( StoreMode . Add , key , Encoding . UTF8 . GetBytes ( value ) , expiresAt ) ) ;
221- }
222-
223- public bool Set ( string key , string value , DateTime expiresAt )
224- {
225- return Execute ( ( ) => client . Store ( StoreMode . Set , key , Encoding . UTF8 . GetBytes ( value ) , expiresAt ) ) ;
226- }
227-
228- public bool Replace ( string key , string value , DateTime expiresAt )
229- {
230- return Execute ( ( ) => client . Store ( StoreMode . Replace , key , Encoding . UTF8 . GetBytes ( value ) , expiresAt ) ) ;
231- }
232-
233189 public bool Add ( string key , object value )
234190 {
235191 return Execute ( ( ) => client . Store ( StoreMode . Add , key , value ) ) ;
@@ -260,44 +216,14 @@ public bool Replace(string key, object value, DateTime expiresAt)
260216 return Execute ( ( ) => client . Store ( StoreMode . Replace , key , value , expiresAt ) ) ;
261217 }
262218
263- public bool Append ( string key , byte [ ] data )
264- {
265- return Execute ( ( ) => client . Append ( key , data ) ) ;
266- }
267-
268- public bool Prepend ( string key , byte [ ] data )
269- {
270- return Execute ( ( ) => client . Prepend ( key , data ) ) ;
271- }
272-
273219 public bool CheckAndSet ( string key , object value , ulong cas )
274220 {
275- return Execute ( ( ) => client . CheckAndSet ( key , value , cas ) ) ;
276- }
277-
278- public bool CheckAndSet ( string key , byte [ ] value , int offset , int length , ulong cas )
279- {
280- return Execute ( ( ) => client . CheckAndSet ( key , value , offset , length , cas ) ) ;
281- }
282-
283- public bool CheckAndSet ( string key , object value , ulong cas , TimeSpan validFor )
284- {
285- return Execute ( ( ) => client . CheckAndSet ( key , value , cas , validFor ) ) ;
221+ return Execute ( ( ) => client . Cas ( StoreMode . Replace , key , value , cas ) . Result ) ;
286222 }
287223
288224 public bool CheckAndSet ( string key , object value , ulong cas , DateTime expiresAt )
289225 {
290- return Execute ( ( ) => client . CheckAndSet ( key , value , cas , expiresAt ) ) ;
291- }
292-
293- public bool CheckAndSet ( string key , byte [ ] value , int offset , int length , ulong cas , TimeSpan validFor )
294- {
295- return Execute ( ( ) => client . CheckAndSet ( key , value , offset , length , cas , validFor ) ) ;
296- }
297-
298- public bool CheckAndSet ( string key , byte [ ] value , int offset , int length , ulong cas , DateTime expiresAt )
299- {
300- return Execute ( ( ) => client . CheckAndSet ( key , value , offset , length , cas , expiresAt ) ) ;
226+ return Execute ( ( ) => client . Cas ( StoreMode . Replace , key , value , expiresAt , cas ) . Result ) ;
301227 }
302228
303229 public void FlushAll ( )
@@ -334,7 +260,15 @@ public IDictionary<string, object> GetAll(IEnumerable<string> keys, out IDiction
334260 {
335261 //Can't call methods with 'out' params in anonymous method blocks
336262 //Calling client directly instead - Add try{} if warranted.
337- return client . Get ( keys , out casValues ) ;
263+
264+ var retVal = new Dictionary < string , object > ( ) ;
265+ casValues = new Dictionary < string , ulong > ( ) ;
266+ foreach ( var casResult in client . GetWithCas ( keys ) )
267+ {
268+ retVal . Add ( casResult . Key , casResult . Value . Result ) ;
269+ casValues . Add ( casResult . Key , casResult . Value . Cas ) ;
270+ }
271+ return retVal ;
338272 }
339273
340274 public void RemoveAll ( IEnumerable < string > keys )
0 commit comments