The API supports caching for certain methods. Right now those are:
To enable caching for a method call, the parameter maxResultAge needs be specified, either on
the query string or in a SOAP header.
GetSearchResult with caching, using the query string
01: [STAThread]
02: static void Main(string[] args) {
03:
04: try {
05: string appId = "yourAppId"; // Use your application Id
06: string appServiceKey = "yourAppServiceKey"; // Use your application service key
07:
08: Tradera.Api.PublicService publicService = new Tradera.Api.PublicService();
09:
10: publicService.Url += string.Format("?appId={0}&appKey={1}", appId, appServiceKey);
11:
12: // Allow results that has been cached for a maximum of 60 seconds.
13: publicService.Url += "&maxResultAge=60";
14:
15: Tradera.Api.SearchResult searchResult = publicService.GetSearchResult("ipod", 0, 1,
16: Tradera.Api.SearchOrderBy.EndDateAscending);
17:
18: Console.WriteLine("Number of items returned: {0} Total: {1}",
19: searchResult.Items.Length, searchResult.TotalNumberOfItems);
20:
21: searchResult = publicService.GetSearchResult("ipod", 0, 1,
22: Tradera.Api.SearchOrderBy.EndDateAscending);
23:
24: Console.WriteLine("Number of items returned (cached): {0} Total: {1}",
25: searchResult.Items.Length, searchResult.TotalNumberOfItems);
26:
27: Console.ReadLine();
28:
29: } catch(Exception exception) {
30:
31: Console.WriteLine("Error: {0}", exception.Message);
32: Console.WriteLine(exception.StackTrace);
33: Console.ReadLine();
34: }
35: }
Remarks
-
Add your application Id and application service key on lines 5 and 6.
-
Use the name you gave your web reference in place of the Tradera.Api prefix used in lines 8, 15, 16 and 22.
GetSearchResult with caching, using SOAP header
01: [STAThread]
02: static void Main(string[] args) {
03:
04: try {
05: int appId = yourAppId; // Use your application Id
06: string appServiceKey = "yourAppServiceKey"; // Use your application service key
07:
08: Tradera.Api.PublicService publicService = new Tradera.Api.PublicService();
09:
10: publicService.AuthenticationHeaderValue = new Tradera.Api.AuthenticationHeader();
11: publicService.AuthenticationHeaderValue.AppId = appId;
12: publicService.AuthenticationHeaderValue.AppKey = appServiceKey;
13:
14: publicService.ConfigurationHeaderValue = new Tradera.Api.ConfigurationHeader();
15:
16: // Allow results that has been cached for a maximum of 60 seconds.
17: publicService.ConfigurationHeaderValue.MaxResultAge = 60;
18:
19: Tradera.Api.SearchResult searchResult = publicService.GetSearchResult("ipod", 0, 1,
20: Tradera.Api.SearchOrderBy.EndDateAscending);
21:
22: Console.WriteLine("Number of items returned: {0} Total: {1}",
23: searchResult.Items.Length, searchResult.TotalNumberOfItems);
24:
25: searchResult = publicService.GetSearchResult("ipod", 0, 1,
26: Tradera.Api.SearchOrderBy.EndDateAscending);
27:
28: Console.WriteLine("Number of items returned (cached): {0} Total: {1}",
29: searchResult.Items.Length, searchResult.TotalNumberOfItems);
30:
31: Console.ReadLine();
32:
33: } catch(Exception exception) {
34:
35: Console.WriteLine("Error: {0}", exception.Message);
36: Console.WriteLine(exception.StackTrace);
37: Console.ReadLine();
38: }
39: }
Remarks
-
Add your application Id and application service key on lines 5 and 6.
-
Use the name you gave your web reference in place of the Tradera.Api prefix used in lines 8, 10, 14, 19, 20 and 26.