This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with File.lastModified()

 
Evgeniy Sedyshev
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my project I use read-cache, so before every read, first of all, check File.lastModified() and then, if it differs from previous value (that I saved during previous cache update), I reload cache, otherwise read performed only from cache.
But when one application updates file using RAF (for example adds new record), File.lastModified() in other application still returns old value (while File.length() returns new length) and no cache update performed (

In case of adding new record I can solve this problem by checking modification time and length together. But in case of modifying.... ((

I already tried "rws" and "rwd" parameters of RAF constructor, but it has no effect

I can see only two ways:
1. Do not anything, because my DataFileAccessObject is Singleton and in case of network mode it will be only one instance of it. And in local mode it's very strange to have two applications with one shared db file.
2. To set last modification time by hands, by calling method File.setLastModified().

What do you thing about that?
[ October 13, 2004: Message edited by: Evgeniy Sedyshev ]
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Evgeniy Sedyshev:
In my project I use read-cache, so before every read, first of all, check File.lastModified() and then, if it differs from previous value (that I saved during previous cache update), I reload cache, otherwise read performed only from cache.
But when one application updates file using RAF (for example adds new record), File.lastModified() in other application still returns old value (while File.length() returns new length) and no cache update performed (

In case of adding new record I can solve this problem by checking modification time and length together. But in case of modifying.... ((

I already tried "rws" and "rwd" parameters of RAF constructor, but it has no effect

I can see only two ways:
1. Do not anything, because my DataFileAccessObject is Singleton and in case of network mode it will be only one instance of it. And in local mode it's very strange to have two applications with one shared db file.
2. To set last modification time by hands, by calling method File.setLastModified().

What do you thing about that?

[ October 13, 2004: Message edited by: Evgeniy Sedyshev ]


My instructions are quite explicit that only one program will be modifying the file at a time. Concurrent users of the server must be dealt with, but concurrent users of the file need not. Here's what my instructons say under locking:

"you may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple clients of your server"
 
Evgeniy Sedyshev
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah, I have the same instructions
realy big thanks

but I also found one solution: I use to raf.getFD().sync() after any modifications to ensure, that data in memory and on disk are the same...
 
Anton Golovin
Ranch Hand
Posts: 527
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Evgeniy. I skip the check altogether because if it is implemented, a locking mechanism for different processes accessing the data file is necessary as well - corrupt data could result otherwise.
 
Inuka Vincit
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Anton said, and if you update your cache in the update and create methods everything will be fine. I chose to use the cahce approach was because it was so much less code to go through a Container type than a whole file, what can I say I am lazy .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic