Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 15th, 2007, 09:29 AM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default run some function when cache reached to limit valu

Hello!

I'm building a forum and I'm thinking on save my "usersOnline" in one list(of T) cached on server!

I don't want do this under SQL because I don't want much Database Traffic.

Let me explain:
I have a Sub that insert members in my OnlineMembersList List or delete members if they LastActivity is bigger than 10 minutes (for example)
But when some user run this function and delete the other members I update my database the lastActivity by this member!

My problem is:
If 3 members are online and make the logout on same time, I loose the opportunity to check if there are any members to delete from the cached list and update DB with lastActivity of this members...
(if cached list deletes reached the limitTimeVlaue)

So I need a way to run one UpdateFunction exactly when the cachetime is reached(Because at this moment the cached list will be deleted..)

Any ideas?

  #2 (permalink)  
Old October 15th, 2007, 09:36 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think what you are looking for is "Cache callbacks". Search Google for some interesting information on this topic.

However, I think you may need to rethink your strategy. The cache is not the right location for this "must keep" data. The items you put in the cache can be trashed by the run-time whenever it sees fit, causing you to loose data about users that are still logged on.

Maybe application state or a database is a better location?

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
  #3 (permalink)  
Old October 15th, 2007, 09:56 AM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar!

I had this with database support on my first application but I'm thinking now to try "cache support"

I didn't know application state!
I saw this:
Quote:
quote:
Because an application and all the objects it stores can be concurrently accessed by different threads, it is better to store only infrequently modified data with application scope. Ideally an object is initialized in the Application_Start event and further access is read-only.
In my case I need to update my list everytime a user browse one page...
But if you think it's faithful than cache... I'm all hears...
What do you think about "only infrequently modified data" should be saved on application_state ?

My problem is because my wife is the forum administrator and she spent much time refreshing the MembersOnline page in order to see who is reading what! I just want to put this list elsewhere but not database! For me is equal cache or application_state! I just want the better.

Application state never expire?

  #4 (permalink)  
Old October 15th, 2007, 10:16 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I agree with your quote on application state. That's how I look at it as well.

This also means you're stuck with the database option as the cache is unreliable by design.

How many users are we talking about? How many database updates?

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
  #5 (permalink)  
Old October 15th, 2007, 10:24 AM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

But the quote says:
"Because an application and all the objects it stores can be concurrently accessed by different threads..."

But remember that if I use Cache, database or Application_State I'll have this "problem"
I'm making multiple updates on one table/list that are being concurrently update/accessed!
I'm I right?

My application has +/- 10 members online (at the same time) for now...
In all my forumPages I have a UpdateFunction and I have 7 pages in my ForumsFolder

Thanks for your attention to this
  #6 (permalink)  
Old October 15th, 2007, 10:35 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, correct. That's why, IMO, the database is the best option. You'll only update a record for the current user, so you're not likely to run into concurrency issues.

With the cache or application state, you do run this risk when two users try to change it at the exact same time.

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
  #7 (permalink)  
Old October 15th, 2007, 12:12 PM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar! I'm understood... DataBase will be!

BTW, what means "IMO" ? :)

Forgive this Portuguese guy!

  #8 (permalink)  
Old October 15th, 2007, 12:19 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

IMO == In My Opinion

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Beginning Visual C# 2008
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
  #9 (permalink)  
Old October 15th, 2007, 12:37 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Great; good luck implementing it.

Doug is right; IMO is the not so humble version of IMHO which stands for In My Humble Opinion....

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Read My Mind by The Killers (Track 6 from the album: Sam's Town) What's This?
  #10 (permalink)  
Old October 15th, 2007, 12:46 PM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok! :)

Thanks for your IMO !

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
network bios command limit reached asp.net app PauliWallnuts ASP.NET 2.0 Professional 2 January 9th, 2008 01:35 PM
How to perform calculation on datagrid column valu Giri C# 1 August 16th, 2006 06:32 AM
how to prompt user if they try to delte wrong valu method ASP.NET 1.x and 2.0 Application Design 4 June 17th, 2005 08:32 AM
Function to run an executable Bob Hansen Access VBA 1 June 25th, 2004 02:10 AM
run function from UserControl melvik C# 11 August 6th, 2003 08:30 AM



All times are GMT -4. The time now is 09:02 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.