473,657 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ObjectDataSourc e caching questions

Hi

I've implemented caching for my ObjectDataSourc e.

<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
EnableCaching=" True" CacheDuration=" 10" CacheExpiration Policy="Sliding "

SelectMethod="G etUsers" TypeName="BizOb ject"></asp:ObjectDataS ource>

This works, however I need to explicitly clear/remove the cache when I
delete record(s). (It's a custom delete, not a ObjectDataSourc e builtin
one.) I understand that I need to set the CacheKeyDepende ncy property so
that I can Remove it from the cache?

When I add this line to the above the cache stops working, i.e. the
SelectMethod retrieves the data from the database each time.

CacheKeyDepende ncy="GVkey"

Can someone point me in the right direction? How do I see what's in the
cache? If I write this out it is always zero even when the cache is working.

Literal1.Text = "The number of items in the cache:" +
Cache.Count.ToS tring();

Very confused. Thanks
Andrew
Apr 10 '06 #1
2 6259
Hi Andrew,

Thank you for posting.

Regarding on the ObjectDataSourc e's caching behavior , here are some of my
understanding and suggestion:

The objectDataSourc e control's cache is maintained internally so that we
can not manually view or query through the Page.Cache or HttpContext.Cac he
collection. And the cache is created and used during the Select method of
the ObjectDataSourc e, that means, when ObjectDataSourc e.Select method is
called, it will check the cache to see whether it should use cache or redo
the query from the underlying data access class. This is different from
the behavior GridView (or other databound control) call
DataSourceContr ol.Select since DataBound control may store data in
ViewState to avoid querying the datasourcecontr ol. In other word, if you
want to test the ObjectDatasourc e control's cache behavior, you can
manually call ObjectDataSourc e.Select method and also put some trace
code(like Httpcontext.Cur rent.Response.W rite...) in the data access
control's select method to check the behavior.

Also, for the "CacheKeyDepend ency", when it is set, that means the
ObjectDataSourc e.Select method will use the cached data only when there is
an existing cache entry in the application Cache and the key of it equals
to the "CacheKeyDepend ency" property wo set on the ObjectDataSourc e
control. So we need to add such a cache entry so that the ObjectDataSourc e
will use the cache, then, when we want to explicitly expire the
ObjectDataSourc e's cache, just remove that entry(we need to readd it if we
want the objectdatasourc e to begin using cache again). e.g:

<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
CacheDuration=" 10"
EnableCaching=" True" SelectMethod="G etProducts"
TypeName="TestD ataObject" CacheKeyDepende ncy="MYKEY">
............... ..

//test method to manually call ObjectDatasourc e.Select method
protected void Button1_Click(o bject sender, EventArgs e)
{
Response.Write( "<br/>Button1_Click" );
ObjectDataSourc e1.Select();
}

//manually remove the cache entry of the objectdatasourc e's KeyDependency
protected void btnInvalid_Clic k(object sender, EventArgs e)
{
Cache.Remove(Ob jectDataSource1 .CacheKeyDepend ency);
}

// set the key entry
protected void Button2_Click(o bject sender, EventArgs e)
{

Cache[ObjectDataSourc e1.CacheKeyDepe ndency] = new object();

}

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Apr 11 '06 #2
Hi,

this is from a post about the ObjectDataSourc e:

"Sometimes we may need to invalidate the cached data for the
ObjectDataSourc e. To do so we can use the CacheKeyDepende ncy property.
When the control caches the data returned from the SelectMethod, it
will check the value of CacheKeyDepende ncy, and if it's set the
cached data will have a dependency on that cache key. When we want to
remove the cached data we can use the Cache.Remove method using the key
specified in the CacheKeyDepende ncy".

If you want to check the full post:

http://www.manuelabadia.com/blog/Per...2f72d0c86.aspx

The ObjectDataSourc e uses the internal cache to store data. To view the
cached data you can use Nikhil's web development helper or Cristian
Civera's ViewState Analyzer.

Hope it helps,

Manu

J055 ha escrito:
Hi

I've implemented caching for my ObjectDataSourc e.

<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
EnableCaching=" True" CacheDuration=" 10" CacheExpiration Policy="Sliding "

SelectMethod="G etUsers" TypeName="BizOb ject"></asp:ObjectDataS ource>

This works, however I need to explicitly clear/remove the cache when I
delete record(s). (It's a custom delete, not a ObjectDataSourc e builtin
one.) I understand that I need to set the CacheKeyDepende ncy property so
that I can Remove it from the cache?

When I add this line to the above the cache stops working, i.e. the
SelectMethod retrieves the data from the database each time.

CacheKeyDepende ncy="GVkey"

Can someone point me in the right direction? How do I see what's in the
cache? If I write this out it is always zero even when the cache is working.

Literal1.Text = "The number of items in the cache:" +
Cache.Count.ToS tring();

Very confused. Thanks
Andrew


Apr 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3498
by: Oldman | last post by:
Is there a way to manually expire the cache for an objectdatasource?
0
1090
by: osh | last post by:
Fellow ASP.net'ers... I am working on a solution that needs to perform a search (search criteria can be as little as 1 and as high as 20 fields) through an average of 25,000 records and return results in a GridView. I only want to return 150 results total, and page through them 10 results at a time - but I also need to grab a count from the MSSQL server as to how many TOTAL records were found. So maybe 4,500 records were found that met...
1
3057
by: Felix_WafyTech | last post by:
Hi, I'm working with the ObjectDatasource and the application is getting more and more chatty. Is there a way I could make the ObjectDatasource support multiple DataTables that could be retrieved as one Dataset? I'm wondering how others out there work with ObjectDatasource? The only option I now see to get this fixed is to manually make the call to the Web services, retrieve the Dataset and assign the datatable to the controls (Or can...
7
5174
by: M C | last post by:
Hi, This is a problem that has been haunting me for days and I've come to a complete dead-end. I'm using a objectdatasource to select and update a gridview control. Populating with select works fine but updating gives the "input string... " error. Any suggestions or links to a working sample. Let me know if anyone needs any code posted... Thanks in advance! MC
10
4564
by: J055 | last post by:
Hi I've been trying out SqlCacheDependency using the ObjectDataSource and SQL Server 2005. It all works quite well with the minimum of configuration, e.g. <asp:ObjectDataSource ID="odsAccounts" runat="server" ... EnableCaching="true" SqlCacheDependency="CommandNotification"> .... </asp:ObjectDataSource>
3
1934
by: Doug Salomon | last post by:
Hi, Recently, my site has been generating errors which say: "Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached." I'm wondering if this might have something to do with the way that we use objectdatasource objects.
2
3185
by: Jami Bradley | last post by:
I'm in need of some design suggestions! We have a fairly large DB with thousands of users accessing data throughout the day. I have been given the task of restructuring a core part of the web application. It will be a design example for the rest of the site and I really want to get it right the first time! Basically we need to present a lot of data to the user. On a single page, we summarize about 5000 rows (grouped so they don't...
1
8570
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but it doesn't seem to work at all. Below is my ASP.NET page, and further below, my VB.NET method that I am trying to call: <div id="admin-faq" class="page"> <h2>Site FAQs (Frequently Asked Questions)</h2>
5
2644
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are simply working with objects in memory. So, it appears as though Microsoft requires that our datamapper classes reside inside a folder called "App_Code", and NO WHERE ELSE. So, has anyone successfully been able to place their datamappers in a...
0
8394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.