-
Scope of the Cache Object
I know you can get and set Cache items from aspx pages but how do you obtain
a reference to the Cache object in the business or data layer classes. I
am attempting to Cache Dataset in memory of lists tables.
e.g.
-- Web Page
Protected Sub PopulateDropDowns()
dim db as new MyNamespace.DataLayer.Lists
ddlProducts.Datasource = db.GetDropDownList(Products)
...
End Sub
-DataLayer (MyNamespace.DataLayer.Lists class)
Public Function GetDropDownList(ListType as ListTypes) As DataView
Dim ds as DataSet
ds = Cache(ListType) 'CACHE OBJECT IS NOT AVAILABLE IN THIS
If ds Is Nothing Then 'NAMESPACE/CLASS
'Get New List from Database
ds = GetList(ListType)
'Add the new list to cache
If not DS is Nothing then Cache.Insert(ListType, ds)
End If
If Not ds Is Nothing Then Return ds.Tables(0).DefaultView
End Function
I've even tried to Imports System.Web.Caching and still doesn't work.
I also tried the following but it doesn't store is in cache but in another
area. It does not have any dependecy options anyway.
Dim c As System.AppDomain
c.CurrentDomain.SetData(Name, Data)
Do I need to pass as reference of the Cache object to the Business & Data
Layers in the constructor?
Any help would be much appreciated.
Thanks
michael
-
Re: Scope of the Cache Object
> Do I need to pass as reference of the Cache object
> to the Business & Data Layers in the constructor?
Michael: That would work. You might also try "HttpContext.Current.Cache"
instead of just "Cache".
--
Phil Weber
-
Re: Scope of the Cache Object
Thanks Phil
"Phil Weber" <philweber@hotmail.com> wrote:
> > Do I need to pass as reference of the Cache object
> > to the Business & Data Layers in the constructor?
>
>Michael: That would work. You might also try "HttpContext.Current.Cache"
>instead of just "Cache".
>--
>Phil Weber
>
-
Re: Scope of the Cache Object
Firstly,
Import System.Web
Then,
add this to Cache in your BAL, DAL
HttpContext.Current.Cache instead of just Cache
Hope it helps
"michael" <mmayfield_NOSPAM@houston.rr.com> wrote:
>
>I know you can get and set Cache items from aspx pages but how do you obtain
>a reference to the Cache object in the business or data layer classes. I
>am attempting to Cache Dataset in memory of lists tables.
>
>e.g.
>-- Web Page
>Protected Sub PopulateDropDowns()
> dim db as new MyNamespace.DataLayer.Lists
> ddlProducts.Datasource = db.GetDropDownList(Products)
> ...
>End Sub
>
>-DataLayer (MyNamespace.DataLayer.Lists class)
>Public Function GetDropDownList(ListType as ListTypes) As DataView
> Dim ds as DataSet
>
> ds = Cache(ListType) 'CACHE OBJECT IS NOT AVAILABLE IN THIS
> If ds Is Nothing Then 'NAMESPACE/CLASS
> 'Get New List from Database
> ds = GetList(ListType)
> 'Add the new list to cache
> If not DS is Nothing then Cache.Insert(ListType, ds)
> End If
>
> If Not ds Is Nothing Then Return ds.Tables(0).DefaultView
>
>End Function
>
>I've even tried to Imports System.Web.Caching and still doesn't work.
>I also tried the following but it doesn't store is in cache but in another
>area. It does not have any dependecy options anyway.
> Dim c As System.AppDomain
> c.CurrentDomain.SetData(Name, Data)
>
>Do I need to pass as reference of the Cache object to the Business & Data
>Layers in the constructor?
>
>Any help would be much appreciated.
>
>Thanks
>michael
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks