c# - Limit number of web service calls within timeframe -
i have asmx web service takes few simple types input, calls oracle stored procedure gets response , passes response caller.
i take inputs service , assuming valid , required operation completed successfully, i'd store inputs somehow (in efficient way, not hitting database example) agreed timespan, refuse attempts call service same data until after timespan has expired. hope that's clear.
so way of pseudo code...
[webmethod] public response dothings(int someint, string somestring, datetime somedatetime) { if(!stored(someint, somestring, somedatetime)) { var response = new oraclerepository().callstoredprocedure(someint, somestring, somedatetime); storeinputs(someint, somestring, somedatetime); return response; } else return response.trylater; } private void storeinputs(int someint, string somestring, datetime, somedatetime) { store(int someint, string somestring, datetime, somedatetime); } private bool stored(int someint, string somestring, datetime, somedatetime) { //some code find out if data stored } i'm not complete beginner, quite new c#, not quite sure start. appreciated.
thanks.
using httpcontext.current.cache should able cache result of stored procedure call , on next request query data , if found return data instead of doing new stored procedure call.
the .add method on cache class has parameters data max age see: http://msdn.microsoft.com/en-us/library/system.web.caching.cache.add.aspx
Comments
Post a Comment