Skip to content

Instantly share code, notes, and snippets.

@vietnt
Created September 5, 2011 08:46
Show Gist options
  • Save vietnt/1194469 to your computer and use it in GitHub Desktop.
Save vietnt/1194469 to your computer and use it in GitHub Desktop.
vs
public Slice Get(Slice key, int transactionId = -1)
{
var record = UseTransaction (transactionId, tr=>tr.Records.FindLast (r=> r.Key == key));
if (record != null) return record.Value;
var r = log.Get(key);
if (v != null) return v;
return InternalGet(key);
}
public Slice Get2(Slice key, int transactionId = -1)
{
return Combine (key,
k =>
{
var record = UseTransaction (transactionId, tr=>tr.Records.FindLast (r=>r.Key == key));
return record != null ? record.Value : null;
},
log.Get,
InternalGet)
.First();
}
public IEnumerable<T> Combine<T,TA>(TA arg, params Func<TA, T> funcs)
{
foreach (var func in funcs)
{
yield return func(arg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment