473,379 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Caching until 23:59 o'clock...

Hi colleagues,

I have a small issue. I don't know how to solve it. I'm caching a
property value : True or False. I do this manually and it works. But I
would like to remove the cache if the the time is 23:59 o'clock. How
can I automatically release the cache at 23:59 or 23:00 o'clock? Look
at line 7. I don't know what the syntax is. Can someone help me?
Idea is if the time raises 23:59:00 o'clock the cache need to be
removed automatically. I only want to cache until the end of the day.
The other day it should be dissapeared.

thanks in advance for your help,
mesut

1 Public Property Frozen() As Boolean
2 GET
3 ' ... END GET
4 Set(ByVal value As Boolean)
5 If value Then
6 Cache(FrozenCacheKey) = True
7 Cache.Insert(FrozenCacheKey, value, Nothing,
DateTime(("23:59:00")))
8 Else
9 If Not Cache(FrozenCacheKey) Is Nothing Then
10 Cache.Remove(FrozenCacheKey)
11 End If
12 End If
13 End Set
End Property

Mar 29 '07 #1
6 2010
On Mar 29, 10:37 am, "mesut" <mesut.de...@noveonbe.comwrote:
Hi colleagues,

I have a small issue. I don't know how to solve it. I'm caching a
property value : True or False. I do this manually and it works. But I
would like to remove the cache if the the time is 23:59 o'clock. How
can I automatically release the cache at 23:59 or 23:00 o'clock? Look
at line 7. I don't know what the syntax is. Can someone help me?
Idea is if the time raises 23:59:00 o'clock the cache need to be
removed automatically. I only want to cache until the end of the day.
The other day it should be dissapeared.

thanks in advance for your help,
mesut

1 Public Property Frozen() As Boolean
2 GET
3 ' ... END GET
4 Set(ByVal value As Boolean)
5 If value Then
6 Cache(FrozenCacheKey) = True
7 Cache.Insert(FrozenCacheKey, value, Nothing,
DateTime(("23:59:00")))
8 Else
9 If Not Cache(FrozenCacheKey) Is Nothing Then
10 Cache.Remove(FrozenCacheKey)
11 End If
12 End If
13 End Set
End Property
I think you can try

DateTime.Parse(DateTime.Now.ToShortDateString() + " 23:59:59")

Mar 29 '07 #2
Hi Alexy,

thanks for your reply...

When I try :
Cache.Insert(FrozenCacheKey, value, Nothing,
DateTime.Parse(DateTime.Now.ToShortDateString() + " 23:59:59"))
I get error: -Overload resolution faield because no accesible
'Insert' acepts this number of arguments.

Cache(FrozenCacheKey) = True with this code line I set the value to
True.
But I would like to cache until 23:59:59 o'clock the same day. Is my
code correct above? I mean I'm using the cache.insert function. Is
this correct?

thanks for your help,

mesut

Mar 29 '07 #3
Hi Alexy,
>
thanks for your reply...

When I try :
Cache.Insert(FrozenCacheKey, value, Nothing,
DateTime.Parse(DateTime.Now.ToShortDateString() + " 23:59:59"))
I get error: -Overload resolution faield because no accesible
'Insert' acepts this number of arguments.
Cache(FrozenCacheKey) = True with this code line I set the value to
True.
But I would like to cache until 23:59:59 o'clock the same day. Is my
code correct above? I mean I'm using the cache.insert function. Is
this correct?
thanks for your help,

mesut
Instead of going through ToString() and Parse(), you could use
DateTime.Today.Add(new TimeSpan(23,59,59))

The Cache.Insert method requires another parameter, use
System.Web.Caching.Cache.NoSlidingExpiration

(it's used to set a "sliding expiration": expire when it hasn't been
accessed within this time. NoSlidingExpiration disables this)

Hans Kesting
Mar 29 '07 #4
On Mar 29, 12:00 pm, "mesut" <mesut.de...@noveonbe.comwrote:
I get error: -Overload resolution faield because no accesible
'Insert' acepts this number of arguments.
That's true - http://msdn2.microsoft.com/en-us/lib...he.insert.aspx

I guess you wanted to use

Cache.Insert Method (String, Object, CacheDependency, DateTime,
TimeSpan)
http://msdn2.microsoft.com/en-us/library/4y13wyk9.aspx

which required 5 arguments

and where you've missed a slidingExpiration (the interval between the
time the inserted object is last accessed and the time at which that
object expires)

In your case you can use the Cache.NoSlidingExpiration value

Mar 29 '07 #5
Super thanks Alexey and Hans,

Both works.... thaks you very much for your help again,

cheers, mesut :)

Mar 29 '07 #6
On Mar 29, 12:13 pm, Hans Kesting <news.2.han...@spamgourmet.com>
wrote:
Instead of going through ToString() and Parse(), you could use
DateTime.Today.Add(new TimeSpan(23,59,59))
good idea!

Mar 29 '07 #7

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

Similar topics

6
by: Jacob H | last post by:
Hello all, I'm close to being a novice programmer and I never was good at math. So I'm curious to know ways in which this following code can be made more efficient, more elegant. The code just...
33
by: Pushkar Pradhan | last post by:
I'm using clock() to time parts of my code e.g. clk1 = clock(); /* code */ clk2 = clock(); /* calculate time in secs */ ...... clk1 = clock(); /* code */ clk2 = clock();
2
by: Jeff Shantz | last post by:
Hello, I'm developing a large statistics application for a call center. It often needs to calculate time spanning over months. For example, an agent's total talk time within 30 days. Since an...
3
by: Pål Johansen | last post by:
Is it possible to cache portions of a page client side. I have som include pages that I would like to store at the clients cache.
10
by: dave Cheseldine | last post by:
Hi I want to stop a gd generated image from being cached. It is called into index.php file as follows: <image src = "http://www.daveches.co.uk/importimage/importimage.php?x=$randomNumber"...
54
by: CoreyWhite | last post by:
The following experiment is a demonstration of TIME TRAVEL. When writing this program, and testing it out I found that sometimes the program would engage itself in time travel but other times it...
4
seshu
by: seshu | last post by:
Hi everybody This is seshu i have small doubt in adding times to a combobox form 00:00:00 to 23:00:59 because there are two comboboxes in my table and i want to use them as...
8
by: Joe Kovac | last post by:
Hi! I want the user to edit a textbox which allows following values only: - Time (Format: 23:59, HH:MM) or - NULL (empty string) What can I do, so that this works kinda automatically, meaning...
0
docdiesel
by: docdiesel | last post by:
The fastest (and cheapest) transfer of data is that which doesn't have to be done - because the data is already there. Or still there - the caching of files is widely known and practised. Each web...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.