473,804 Members | 3,018 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

persistent cache in SQL Server

Hello,
I'm developing an asp.net application that is connected to a remote system
using WCF (wshttp binding). So I want to use a local cache to manage data
that I receive from remote service.

I'm using caching block from MS application enterprise library 4.1,
configured to use a SQL Server cache. That's great: it works with very
little effort.
However I noticed that caching block mantains a copy of the cache in memory
(loading all cache when it starts). I want to matain data only in SQL
Server, because are very large data that I mantain in cache for a lot of
time (about 7 days). Is there any way I can use ONLY the SQL Server
repository instead of in.memory AND Sql Server?

thanks


Nov 14 '08 #1
5 2670
The idea behind cache, as MS has it, is to save time getting information by
putting it in memory. SQL is there as a backup, but it is not designed to be
a primary mechanism, as SQL retrievals are slower than memory. If you want
to store long term temporary infomration in SQL and not really cache,
consider rolling your own mechanism rather than use the MS cache bits, as
you are not really caching here.

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*************** *************** **************
| Think Outside the Box! |
*************** *************** **************
"Trapulo" <tr******@noema il.noemailwrote in message
news:DF******** *************** ***********@mic rosoft.com...
Hello,
I'm developing an asp.net application that is connected to a remote system
using WCF (wshttp binding). So I want to use a local cache to manage data
that I receive from remote service.

I'm using caching block from MS application enterprise library 4.1,
configured to use a SQL Server cache. That's great: it works with very
little effort.
However I noticed that caching block mantains a copy of the cache in
memory (loading all cache when it starts). I want to matain data only in
SQL Server, because are very large data that I mantain in cache for a lot
of time (about 7 days). Is there any way I can use ONLY the SQL Server
repository instead of in.memory AND Sql Server?

thanks

Nov 15 '08 #2
Yes: I need a cache that saves time getting data from remote WCF Server,
instead of saving data from getting data from SQL Server. So SQL is a lot
faster that a remote WCF call and I need a "real cache"...

Is there some ready library I can use someone can suggest? I not want to
write my own code to have a very common scenario...

thanks

"Gregory A. Beamer" <No************ @comcast.netNoS pamMwrote in message
news:uP******** ******@TK2MSFTN GP02.phx.gbl...
The idea behind cache, as MS has it, is to save time getting information
by putting it in memory. SQL is there as a backup, but it is not designed
to be a primary mechanism, as SQL retrievals are slower than memory. If
you want to store long term temporary infomration in SQL and not really
cache, consider rolling your own mechanism rather than use the MS cache
bits, as you are not really caching here.

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*************** *************** **************
| Think Outside the Box! |
*************** *************** **************
"Trapulo" <tr******@noema il.noemailwrote in message
news:DF******** *************** ***********@mic rosoft.com...
>Hello,
I'm developing an asp.net application that is connected to a remote
system using WCF (wshttp binding). So I want to use a local cache to
manage data that I receive from remote service.

I'm using caching block from MS application enterprise library 4.1,
configured to use a SQL Server cache. That's great: it works with very
little effort.
However I noticed that caching block mantains a copy of the cache in
memory (loading all cache when it starts). I want to matain data only in
SQL Server, because are very large data that I mantain in cache for a lot
of time (about 7 days). Is there any way I can use ONLY the SQL Server
repository instead of in.memory AND Sql Server?

thanks

Nov 17 '08 #3
Hi Trapulo,

From your description you want to store the data into SQL Server that is
retrieved from WCF, right? If so, as Gregory said, it's not a cache.

First I need to confirm if you need a global data structure or a
user-independent data structure. If the data is user independent I suggest
you use the ASP.NET Session. As we know, session can be stored in SQL
Server:

http://support.microsoft.com/kb/317604

You can call WCF method and store the retrieved data into Session.
If it's global data you can design a table:

Key P.K.
Value
TimeStamp

Then store the retrieved data into database and use Sql Server Agent
Service to remove the expired records every 7 days.

Please let me know if you have any questions.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 18 '08 #4
"Allen Chen [MSFT]" <v-******@online.m icrosoft.comwro te in message
news:qx******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Trapulo,

From your description you want to store the data into SQL Server that is
retrieved from WCF, right? If so, as Gregory said, it's not a cache.
Yes
However I think it's sure a cache

http://en.wikipedia.org/wiki/Cache:
"In computer science, a cache (pronounced /kæʃ/) is a collection of data
duplicating original values stored elsewhere or computed earlier, where the
original data is expensive to fetch (owing to longer access time) or to
compute, compared to the cost of reading the cache"
First I need to confirm if you need a global data structure or a
user-independent data structure
global data.
If the data is user independent I suggest
you use the ASP.NET Session. As we know, session can be stored in SQL
Server:

http://support.microsoft.com/kb/317604

You can call WCF method and store the retrieved data into Session.
this can be interesting. However, as I said, data are global
If it's global data you can design a table:

Key P.K.
Value
TimeStamp

Then store the retrieved data into database and use Sql Server Agent
Service to remove the expired records every 7 days.

Please let me know if you have any questions.
Ok thanks.
I was hoping to find a full featured complete library (as logging block).
In fact, however, it can be good to have a copy either in memory and sql
server. But logging block retains in memory all data. If it can retain, for
example, last 100 objects in memory, and 10000 in sql, it will be great (100
is too little to my requirenments, an 10000 is to big to leave in memory).
Instead of this, it has just a single parameter that sets memory and sql
cache. Is there any easy way we can extend logging block to have this goal?

thanks

Nov 18 '08 #5
Hi Trapulo,

Quote from Trapulo =============== =============== =============== ====
In fact, however, it can be good to have a copy either in memory and sql
server. But logging block retains in memory all data. If it can retain, for
example, last 100 objects in memory, and 10000 in sql, it will be great
(100
is too little to my requirenments, an 10000 is to big to leave in memory).
Instead of this, it has just a single parameter that sets memory and sql
cache.
=============== =============== =============== ====

As far as I know currently the enterprise library does not provide that
flexibility. The SQL data storage for the caching block is mainly used to
backup cached data in case in-memory cache is lost due to application
crash. It's not proposed as a primary cache.

To achieve your requirement we can write our own cache mechanism. The
pseudocode may be:

using System.Web.Cach ing;

public class MyCacheManager
{
private static Cache _cache = new Cache();
public static void AddCache(object data,object key)
{

if (_cache.Count 100)
{
//insert data to database
}
else
{
//add data to _cache
//optional, add a copy to database in case in-memory cache
is lost.
}
}
public static object GetCache(object key)
{
//if the data retrieved from _cache is null, access database
//if still no record retrieved, return null.
}

}

We can design a table to store the data and use SQL Server agent to remove
records every 7 days.

You can also consider using distributed caching. Though it's not the means
as you thought above it's another option that can increase performance.
http://www.codeplex.com/SharedCache

If you have further questions please feel free to ask.

Regards,
Allen Chen
Microsoft Online Community Support

Nov 20 '08 #6

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

Similar topics

5
2819
by: Felix E. Klee | last post by:
I've set up a PHP web application where users can log in and open a connection to a NNTP-server. There is a *one-to-one* relationship between sessions and NNTP-connections (i.e. exactly one NNTP-connection per session, and exactly one session per NNTP-connection). Now, I'd like to have these connections be persistent. So I started using "pfsockopen" instead of "fsockopen" and set Apache's KeepAliveTimeout to a very high value. ...
16
3322
by: Paul Rubin | last post by:
I've had this recurring half-baked desire for long enough that I thought I'd post about it, even though I don't have any concrete proposals and the whole idea is fraught with hazards. Basically I wish there was a way to have persistent in-memory objects in a Python app, maybe a multi-process one. So you could have a persistent dictionary d, and if you say d = Frob(foo=9, bar=23) that creates a Frob instance and stores it in d. Then if...
3
25744
by: Dan Berg | last post by:
In my event log on my IIS 6.0 Windows 2003 Server I get the following Active Server Pages Error Error: The Template Persistent Cache initialization failed for Application Pool 'DefaultAppPool' because of the following error: Could not create a Disk Cache Sub-directory for the Application Pool. The data may have
2
1786
by: DartmanX | last post by:
I have an application that uses the Google Maps API to display customized maps via a generated XML file. The XML is generated via a "Wizard" system to determine what the XML holds. I am looking for a way to keep the XML file "persistent" across the pages via Javascript. The way the Maps API works is that the Client feeds the items to be mapped to google, which generates the maps. Storing the XML file on the server would mean I would have...
1
4943
by: Jeff | last post by:
I am new to web services and want to expose a C# program through web services (soap or otherwise) that will have a service with cached data running on a server that clients can make requests to without instanciating the (data) classes locally. I see many examples of using web services where the server really just handles requests to point to XML serialized classes that have to be instanciated locally on the client. This is no good for me...
1
1586
by: Ryan | last post by:
The real reason for my previous post about intercepting Application_EndRequest (from outside of Global.asax) is because of a need to create a "non persistent page level cache". I can't seem to find an intrinsic property that exposes a Hashtable that gets reset for every page request. If someone knows of such a property, please let me know! Page.Cache is alive through an application domain. ViewState, of course, is persisted between...
2
1958
by: NWx | last post by:
Hi, Is Cache appropriate to store persistent variables used across the application? What I want is to store UserID for currently logged user, SessionID (my own SessionID, which keep track of datetime for login and logout as well as other info, like Client IP , etc) My objects I want store to cache are not set-up to expire. Or should I store them better in Session storage?
4
11535
by: Troy | last post by:
I keep getting this error in IIS 6.0. It causes our web application to display the "Service Unavailable" message when users attempt to visit any asp.net page. all asp pages are fine... does anyone have any suggestions? Thanks... Error: The Template Persistent Cache initialization failed for Application Pool 'DefaultAppPool' because of the following error: Could not create a Disk Cache Sub-directory for the Application Pool. The data...
0
1135
by: Roger | last post by:
Error: The Template Persistent Cache initialization failed for Application Pool 'MSPS2003AppPool' because of the following error: Could not create a Disk Cache Sub-directory for the Application Pool. The data may have additional error codes.. Great error message. No support at the help center. Can someone tell me how to fix it? Thanks
0
9704
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
9572
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6845
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
5508
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
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.