Yii Framework Forum: Multiple Cfilecache Writing To Same File At The Same Time - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Multiple Cfilecache Writing To Same File At The Same Time Rate Topic: -----

#1 User is offline   pommeverte 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 15-March 11

Posted 24 January 2013 - 09:25 PM

Hey guys, I've ran into a bit of an issue using CFileCache. Basically if two simultanous page loads write to the same cache file this can (and has) result in corruption of data in that file.

I was wondering if I was missing anything to do with locking or similar that would already be implemented. Or do I have to come up with my own solution?

Thanks in advance
0

#2 User is offline   redguy 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 809
  • Joined: 02-July 10
  • Location:Central Poland

Posted 25 January 2013 - 06:04 AM

CFileCache writes data with:
file_put_contents($cacheFile,$value,LOCK_EX)!

and LOCK_EX flag according to PHP documentation stands for "Acquire an exclusive lock on the file while proceeding to the writing."

so... it should not cause problems with simultaneous access...
red
1

#3 User is offline   pommeverte 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 15-March 11

Posted 25 January 2013 - 06:08 PM

View Postredguy, on 25 January 2013 - 06:04 AM, said:

CFileCache writes data with:
file_put_contents($cacheFile,$value,LOCK_EX)!

and LOCK_EX flag according to PHP documentation stands for "Acquire an exclusive lock on the file while proceeding to the writing."

so... it should not cause problems with simultaneous access...



That's very interesting!! I didn't check that far in. In that case I'm indeed mistaking and the issue lays elsewhere (mea culpa).
Maybe the issues lay in the locks of the files used to generate the cache file content.

Thanks a lot!!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users