How To Use Data Caching With Sql Dependency
Dec 2, 2010
We store the location information in a table. Numbers of records are over four thousand. This table structure is self-recursive. In our web project, we use dropdownlist control to populate all these locations. We got performance slow problem. So googling about Caching, we consider to use Data Caching with Sql Dependency. However, not found yet a full-covered sample in .NET 2.0 and SQL Server 2005 or 2008.
View 1 Replies
Similar Messages:
Sep 21, 2010
I plan to use output cache for my page and also specify sql dependencyi succeded in doing it the following way
[Code]....
Suppose if i want to implement a dependency on the sql query , i create an sqlcache dependency object and specify the sql command to it.Set the notifications .But how do i add this sqldependency to the output cache?For example: if i need to add a file dependency, i give something like Response.AddFileDependency ("filepath"); is there any similiar command available for sqldependency as well? I'm confused about this because, most of the examples i've looked into, does a cache.insert , which defeats my purpose as it's object caching and not output caching. In a nutshell, is it possible to attach a sqlcachedependency to o/p cache inside the controller action
View 3 Replies
Feb 15, 2011
How do I setup caching for a Page in ASP.NET and give it a cache key dependency? I am familiar how to do this with a UserControl, I set a Partial Caching attribute and then set
this.CachePolicy = new CacheDependency(..)
How would I do this for a Page? It does not have a CachePolicy object,
View 1 Replies
Sep 29, 2010
TL;DR: Which is likely faster: accessing static local variable, accessing variable stored in HttpRuntime.Cache, or accessing variable stored in memcached?At work, we get about 200,000 page views/day. On our homepage, we display a promotion. This promotion is different for different users, based on their country of origin and language.
All the different promotions are defined in an XML file on each web server. We have 12 web servers all serving the same site with the same XML file. There are about 50 different promotion combinations based on country/language. We imagine we'll never have more than 200 or so (if ever) promotions (combinations) total.
The XML file may be changed at any time, out of release cycle. When it's changed, the new definitions of promotions should immediately change on the live site. Implementing the functionality for this requirement is the responsibility of another developer and I.
Originally, I wrote the code so that the contents of the XML file were parsed and then stored in a static member of a class. A FileSystemWatcher monitored changes to the file, and whenever the file was changed, the XML would be reloaded/reparsed and the static member would be updated with the new contents. Seemed like a solid, simple solution to keeping the in-memory dictionary of promotions current with the XML file. (Each server doing this indepedently with its local copy of the XML file; all XML files are the same and change at the same time.)
The other developer I was working holds a Sr. position and decided that this was no good. Instead, we should store all the promotions in each server's HttpContext.Current.Cache with a CacheDependency file dependency that automatically monitored file changes, expunging the cached promotions when the file changed. While I liked that we no longer had to use a FileSystemWatcher, I worried a little that grabbing the promotions from the volitile cache instead of a static class member would be less performant.
(Care to comment on this concern? I already gave up trying to advocate not switching to HttpRuntime.Cache.)
Later, after we began using HttpRuntime.Cache, we adopted memcached with Enyim as our .NET interface for other business problems (e.g. search results). When we did that, this Sr. Developer decided we should be using memcached instead of the HttpRuntime (HttpContext) Cache for storing promotions. Higher-ups said "yeah, sounds good", and gave him a dedicated server with memcached just for these promotions. Now he's currently implementing the changes to use memcached instead.
I'm skeptical that this is a good decision. Instead of staying in-process and grabbing this promotion data from the HttpRuntime.Cache, we're now opening a socket to a network memcached server and transmitting its value to our web server.This has to be less performant, right? Even if the cache is memcached. (I haven't had the chance to compile any performance metrics yet.)On top of that, he's going to have to engineer his own file dependency solution over memcached since it doesn't provide such a facility.
Wouldn't my original design be best? Does this strike you as overengineering? Is HttpRuntime.Cache caching or memcached caching even necessary?
View 2 Replies
Feb 25, 2011
asp.net 2.0 MSVS2005 vb.net
I do this..I pull up a SQL multi view SELECT query (thats a stored proc with 3 SELECT statements in it).
[Code]....
I then run thru dr and dr.nextresult and populate controls with it.
The above is fast.
QUESTION : Can I cache at the SQLcommand level in the above code ?
NOTE: I can NOT use SQL dependency as my query doesnt fit the rules
View 1 Replies
Jun 14, 2010
I have a page with a number of user controls, In one of my user controls I have a button event. I turn on output cache for the user control that has the button and vary by control using the ID property of a hidden field control in the user control. whenever I turn on the output cache my button event doesn't fire.
View 2 Replies
May 15, 2010
how to implement caching in wcf service using System.Web.Caching
View 2 Replies
May 29, 2010
I want to use SQL Server based Cache dependency without data source control.How can I do it?I am binding data to grid through code.
View 5 Replies
Mar 18, 2010
Is it possible to do data caching in client-side in asp.net and c#.net iam planning to cache a dataset.
if so provide a sample?
View 2 Replies
Mar 17, 2011
My web application is using the asp.net cache object to store data from the database. I am looking for an elegant to invalidate cache objects but haven't come up with anything elegant yet. It is easy to invalidate a single record or a list of all records in a single table, by keeping track of their cache keys. However I may have any number of lists of subsets of a table's data. I would like to invalidate only the cache records of the lists that contain a particular record, when that record changes. I don't want to have to invalidate all the lists of data for that table if only one of the lists contain that record.
View 1 Replies
Jan 28, 2011
I have a reporting page with a gridview and a calendar. When the user loads the page, the default date is today and when he clicks on a date in the calendar control, it loads the reporting data for that day. Each user has a different report and the data is between 300-500 rows per day. At the moment, I have a linq query that returns the data for a day in the form of a list. Given the relatively small amount of data per query, I'd like to store the result of the query in the session so that I can do the paging and sorting from the session, without going back to the data store.
What I'm looking to do is a list of lists so that when the query loads, the data is saved until the session times out. For instance, if the user selects 4-5 different dates, each of these queries is saved in the session and then if he clicks on one of those dates again, a function first checks to see if the data is in the session: GetQueryFromSession( DateTime TheDate). I'm stuck on this. How do you create a list of lists that works with the session object.
View 2 Replies
Mar 31, 2011
What's the best way to cache web site user data in asp.net 4.0? I have a table of user settings that track all kinds of user or session specific stuff like the state of UI elements (open/closed), preferences, whether some dialog has been dismissed, and so on. Since these don't change very often (for each user, anyway) but are looked up frequently it seems sensible to cache them. What's the best way? These are the options I've identified...
Store them in HttpContext.Current.Session directly (e.g. Session["setting_name"]) Store them in HttpContext.Current.Cache Use a global static dictionary, e.g. static ConcurrentDictionary<string,string> where the key is a unique userID + setting name value Store a dictionary object for each session in Session or Cache What's the most sensible way to do this? How does Session differ from Cache from a practical standpoint? Would it ever make sense to store a dictionary as a single session/cache object versus just adding lots of values directly? I would think lookups might be faster, but updates would be slower since I'd have to re-store the entire dictionary when it changed.
What problems or benefits might there be to using a global static cache? Seems like this would be the fastest, but I'd have to manage the size. I could just flush it periodically if it hits a certain size, or keep a cross reference queue and remove things oldest first when it gets to a certain size. Does this make any sense or is it just trying too hard?
View 2 Replies
May 12, 2010
I have built my first MVC solution and used the repository pattern for retrieving/inserting/updating my database.
I am now in the process of refactoring and I've noticed that a lot of (in fact all) the methods within my repository are hitting the database everytime. This seems overkill and what I'd ideally like is to do is 'cache' the main data object e.g. 'GetAllAdverts' from the database and to then query against this cached object for things like 'FindAdvert(id), AddAdvert(), DeleteAdvert() etc..'
I'd also need to consider updating/deleting/adding records to this cache object and the database.
What is the best apporoach for something like this?
My knowledge of this type of things is minimal and really looking for advice/guidance/tutorial to point me in the right direction.
View 2 Replies
Aug 20, 2010
I have a large SQL Database in the server from which I can create a dataset of about 10000 rows. My question is about caching this data. Which type of data caching should I choose (Server side or Client side)? Which one will provide better performance?
View 5 Replies
Feb 16, 2011
We are developing a multi-language web application with ASP.NET MVC 2 and Fluent NHibernate.Our platform will be multi-language. But just static text will be multi-language. Groups pages depends on community content whatever they use. Like Facebook.We decide to keep all language string in database. And load language when application starts.
View 1 Replies
Jul 17, 2010
I am using page caching in one form they retrive some rows from data base for example i put caching time to 5 minutes, in between 5 min suppose the data has modified in server then it should be reflected in my form how to achieve this problem
View 1 Replies
Sep 17, 2010
My requirement is to call WCF web service from ASP.NET code behind and pass some data for example:void Add(int x, int y);Result of the operation should be somehow stored within WCF web service (member variable).
Later user should be able to call double Equals();and get the result of the operation. Of course since it's an open website many non-authenticated users can open the ASP.NET page and call the web service.
Alternatively Add method can return "key" that can be used to get result back,
[code]...
View 1 Replies
Jul 26, 2010
I have a List (Table) of Data that I display in a Grid View. For now lets just assume I have a List<CustomObject> cList that I give to my GridView.DataSource(). I have a AJAX call (from a DropDown on the Page) that enables me to filter the Data in the GridView. This works. For now, I re-fetch the data from the DB, and filter it.I am wondering if there is a more efficient way of doing this i.e. to save the data the first time I get it, and then display a filtered list of that data when requested. I attempted to save the data as private variable on the Page, but it seems that Page gets recreated for the AJAX call. My attempt looks like:
[Code]....
[Code]....
This page is accessible anonymously - so there is no User Profile or something like that. P.S. I put my code in the Insert Code Dialog, but it does not seem to format it correctly. Sorry about that.
View 2 Replies
Jul 5, 2010
I think there are some steps to enable SQL Cache Depdndency :Enabling notifications, changes in web.xml and then using Cache Dependency object.
View 2 Replies
Jul 20, 2010
I have a page using an injected BLL service: a simple service returning a set of objects with a function like this:
public IMyService { List<Foo> All(); }
There is a default implementation for normal users.Now, i need that users in administrative role can view more objects, with another implementation of the service.Where can i configure my page to use the second implementation?
My first solution is to put the dependency to the IUnityContainer in the page, and use it to resolve the dependency:
[Dependency]
public IUnityContainer Container { get; set;}
Page_Init(..) [code].....
it's a ServiceLocator and it's neither scalable neither testable.
View 2 Replies
Jan 3, 2011
During the design of a new generic authentication framework for some of our products, I have come across an architectural issue I cannot seem to find a good solution for.I have tried to simplify the problem in order to easily explain it.
The library has two classes:
Manager Is responsible for storing currently authenticated users.Module It is the responsibility for the module to validate each request according to security policies. The Module must ask the manager to determine whether a user is currently authenticated.
Now the manager is supplied an implementation of an interface which allows the manager to load users from a repository. The specific implementation is not contained in this library. Because of this, I cannot directly instantiate an instance of the repository within the library.
I have no way of modifying properties or supplying arguments for the module constructor. So my question is this, how can I give the module a reference to an instance of the Manager?
namespace Demo
{
public interface IRepository
{[code].....
View 4 Replies
Nov 1, 2010
Split off from http://forums.asp.net/t/1618613.aspx
I would like to get your advise on Dependency Inversion..Should i include it as a layer between Business Layer and Repository Layer?
I think its really great when different team members work on DAL n BAL etc or when your database will be changed in future. It actually removes the dependency of the Data provider but over the expense of additional coding overhead. My question is , is it really worth it? If i suggest this layer to my PM and give him the above two reasons then i dnt think he will accept it since most of the time each developer works on his DAL/BAL's, and Change in DB wud be the least of his concerns.
RAD in every layer..
I mean if there are any auto generation tools available for generating repositories etc.I read about MVCContrib Grid and i think its a good option to use for Grid.
If i use Spark ViewEngine then can i still use T4 templates to auto create custom views by customizing templates?
View 2 Replies
May 11, 2010
Background of what I have implmented so far:
I've used datagrid view to show a list on records on page, the list contains huge number of records so paging was required. Since the amount of data was huge it was not advisable to bind the grid with complete data. So, I used custom paging and tweaked the sql statements to get page wise data. Now whenever user clicks next or previous data for current page is fetched from the database and gridview is binded with that much data only.
Now I had to add a checkbox column to the grid so that user can select multiple items on multiple pages and perform an operation (for example send email to selected people in the list). I achieved this by making a template column with checkbox control and keeping a boolean column in the datatable which is binded to the gridview. I've also kept a collection selected checboxes so that the state is maintained on every postback.
I've also used ajax so that user cannot see postback happeneing. Everything works just perfect.Here comes the problem:
Now say I have 5 pages of data to be displayed. I select 3 people from first page and move to next page, this will cause fresh databinding and previous data will be lost.Now I go on and select 3 more people from page 2Finally press the send mail button What is expected here is that the mail should be sent to 6 people but details of only 3 people are available because grid is rebinded.
What is the best way to cach data of selected rows in this case. The number of columns is around 20 out of which I show only 10 columns on screen and others are kept hidden. The values of hidden columns are used while sending the emails.
View 5 Replies
Jan 19, 2010
I've this Gridview of tasks a Hyperlink TemplateField that takes the user to another page where he can accept/reject[buttons] the very task , on clicking accept/reject[buttons] the page redirect the user again to the tasks Gridview , unfortunately , the same task is still there unless if the user manually Press F5[Refresh] I tried the following nothing worked
1- EnableViewState ="false"
2- In the ObjectDataSource , EnableCaching ="false"
3-i tried to use Ajax but it gives me a whole lots of errors from the webconfig ,my website is working ,I can't stop users from accessing my site in order to wrestle with Ajax
the approach I am taking on developing my site is to work in my local machine when I am finished with my changes I literally Copy/Paste the new aspx/aspx.vb overwriting the old file with the new one , this approach is working fine but it causes the server to a bit slow esp. in the first time after change, is there a more Professional way?
View 5 Replies
Apr 26, 2012
I have webpage with three dropdown boxes on left side (Country Dropdownbox, State Dropdownbox, City Dropdownbox) and these dropdown works independently or one box will depend on another. I have a gridview in right side and the results will be binding to the gridiew by selecting the left side dropdown boxes.
I need to implement the caching technology here because the web page loading very slow due to large amount of records. For example if i select any country from the first dropdown box and the other two boxes are default (Selected text is "ALL"), then It should display records related to selected country in gridview.
Further if I select country and state from the respective boxes then it should display the related records in the gridview like so on. Now i want do some caching functionality to improve the performance. I tried caching the Dataset while binding to gridview but in my case the results will not be static becasue user every time will select different options from different dropdown boxes and results will come based on the selected options.
View 1 Replies