tags:

views:

64

answers:

2

I am creating an RSS feed on-demand from a folder of images. The feed creation is pretty expensive on large sets of files obviously, so I am caching the feed after first creation but I'd like to know if I need to re-create the feed when someone calls for it.

I'm thinking that if I could figure out a way to cheaply create a unique hash of all the files and file dates, then when the hash changed I would know to re-generate the feed.

Does anyone have any ideas on how to cheaply create this hash? Is a hash even the right name for what I'm looking to do?

Edit:

I know a FileSystemWatcher exists exactly for this type of thing. But I'm more curious about an on-demand technique to do this. I've had other instances where I've done the same thing and used a file watcher to get the notifications but I figure someone has an idea of what to do when you can't get file changed notifications...

A: 

Attack the problem from the other point of view (if you have access to that code).

When are new files created? Have the code the puts in the new files kickoff regeneration of the rss (static) file.

EDIT: fixed grammar

TimW
+1  A: 

you could select all the files in the folder ordered by modification date descending, then you only need to check the first files data against the last feed creation date and you'd know if you have to create the feed again.

Sam Holder
I had a similar thought using the file time stamps to detect changes. However, deleting some files will not get detected this way.
Jeff Alexander
could you check the modified time on the folder. that would be even quicker (as you wouldn't need to loop through the files) and would also be changed if there are files deleted I think. In fact I just checked this and it seems to work, at least on my machine
Sam Holder
I was able to get most of what I wanted by watching the Folder's modified time.
Jeff Alexander