@@ -160,6 +160,25 @@ public IGetOperationResult<T> PerformGet<T>(string key)
160160 }
161161 }
162162
163+ private bool CreateGetCommand ( string key , out IGetOperationResult result , out IMemcachedNode node , out IGetOperation command )
164+ {
165+ result = new DefaultGetOperationResultFactory ( ) . Create ( ) ;
166+ var hashedKey = this . keyTransformer . Transform ( key ) ;
167+
168+ node = this . pool . Locate ( hashedKey ) ;
169+ if ( node == null )
170+ {
171+ var errorMessage = $ "Unable to locate node with \" { key } \" key";
172+ _logger . LogError ( errorMessage ) ;
173+ result . Fail ( errorMessage ) ;
174+ command = null ;
175+ return false ;
176+ }
177+
178+ command = this . pool . OperationFactory . Get ( hashedKey ) ;
179+ return true ;
180+ }
181+
163182 private bool CreateGetCommand < T > ( string key , out IGetOperationResult < T > result , out IMemcachedNode node , out IGetOperation command )
164183 {
165184 result = new DefaultGetOperationResultFactory < T > ( ) . Create ( ) ;
@@ -179,11 +198,28 @@ private bool CreateGetCommand<T>(string key, out IGetOperationResult<T> result,
179198 return true ;
180199 }
181200
201+ private IGetOperationResult BuildGetCommandResult ( IGetOperationResult result , IGetOperation command , IOperationResult commandResult )
202+ {
203+ if ( commandResult . Success )
204+ {
205+ result . Value = transcoder . Deserialize ( command . Result ) ;
206+ result . Cas = command . CasValue ;
207+ result . Pass ( ) ;
208+ }
209+ else
210+ {
211+ commandResult . Combine ( result ) ;
212+ }
213+
214+ return result ;
215+ }
216+
182217 private IGetOperationResult < T > BuildGetCommandResult < T > ( IGetOperationResult < T > result , IGetOperation command , IOperationResult commandResult )
183218 {
184219 if ( commandResult . Success )
185220 {
186221 result . Value = transcoder . Deserialize < T > ( command . Result ) ;
222+ result . Cas = command . CasValue ;
187223 result . Pass ( ) ;
188224 }
189225 else
@@ -194,6 +230,27 @@ private IGetOperationResult<T> BuildGetCommandResult<T>(IGetOperationResult<T> r
194230 return result ;
195231 }
196232
233+ public async Task < IGetOperationResult > GetAsync ( string key )
234+ {
235+ if ( ! CreateGetCommand ( key , out var result , out var node , out var command ) )
236+ {
237+ _logger . LogInformation ( $ "Failed to CreateGetCommand for '{ key } ' key") ;
238+ return result ;
239+ }
240+
241+ try
242+ {
243+ var commandResult = await node . ExecuteAsync ( command ) ;
244+ return BuildGetCommandResult ( result , command , commandResult ) ;
245+ }
246+ catch ( Exception ex )
247+ {
248+ _logger . LogError ( 0 , ex , $ "{ nameof ( GetAsync ) } (\" { key } \" )") ;
249+ result . Fail ( ex . Message , ex ) ;
250+ return result ;
251+ }
252+ }
253+
197254 public async Task < IGetOperationResult < T > > GetAsync < T > ( string key )
198255 {
199256 if ( ! CreateGetCommand < T > ( key , out var result , out var node , out var command ) )
0 commit comments