Skip to content

Instantly share code, notes, and snippets.

@asimmon
Last active October 25, 2016 14:27
Show Gist options
  • Save asimmon/aacecf21d70ccd5e3496 to your computer and use it in GitHub Desktop.
Save asimmon/aacecf21d70ccd5e3496 to your computer and use it in GitHub Desktop.
Caching method results with AOP, call
Console.WriteLine(worker.Process("foo"));
Console.WriteLine(worker.Process("foo"));
Console.WriteLine(worker.Process("foo"));
Console.WriteLine("Sleeping 2 seconds...");
Thread.Sleep(2000);
Console.WriteLine(worker.Process("foo"));
// result
// b7d719b45a01469797c974164179b4b5
// b7d719b45a01469797c974164179b4b5
// b7d719b45a01469797c974164179b4b5
// Sleeping 2 seconds...
// f2ad87faf4fa4daa98ad1fc3e87fde37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment