Re: Cache FileEngine

2011-10-29 Thread Sandreu
Hi.
You're right, windows supports flock i read quickly flock description,
and I mixed up with the non blocant parameters.

Then it should be OK on windows.


On 29 oct, 00:34, 0x20h k...@informatik.uni-marburg.de wrote:
 Hi Sebastien,

 please readhttp://book.cakephp.org/2.0/en/contributing/code.html
 to find out how you can contribute patches.

 Am 28.10.2011 15:30, schrieb Sandreu: Hello,

  I made an increment for file engine system.
  My problem was that in APC cache, the cache is not shared between CLI
  and the web app... then I did that with fileEngine using flock... it's
  not workink on windows.

 why would it not work on windows? I didn't find such a hint on the
 flock() docs.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Cache FileEngine

2011-10-28 Thread Sandreu
Hello,

I made an increment for file engine system.
My problem was that in APC cache, the cache is not shared between CLI
and the web app... then I did that with fileEngine using flock... it's
not workink on windows.




?php

/**
 * FileEngine with inc/dec
 *
 * @author Sandreu
 *
 * @property SplFileObject $_File
 */

App::import('Cache/Engine', 'FileEngine');

class FileIncEngine extends FileEngine {

public function increment($key, $offset = 1) {
if ($this-settings['isWindows']) throw new
CacheException(__d('cake_dev', 'Files cannot be atomically decremented
on windows.'));
if (!$this-_init || $this-_setKey($key) === false) {
if (!$this-write($key, $offset, $this-
settings['duration'])) return false;
return $offset;
}

$lock = $this-settings['lock'];
$this-settings['lock'] = false;

$this-_File-flock(LOCK_EX);

$val = $this-read($key);
if (!is_integer($val)) {
$this-_File-flock(LOCK_UN);
return false;
} else {
$val += $offset;
}

$this-_File-rewind();
if (!$this-write($key, $val, $this-settings['duration']))
{echo 'error'; return false; }

$this-_File-flock(LOCK_UN);

$this-settings['lock'] = $lock;
return $val;
}

public function decrement($key, $offset = 1) {
return $this-increment($key, 0-$offset);
}
}

?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Cache FileEngine

2011-10-28 Thread 0x20h
Hi Sebastien,

please read
http://book.cakephp.org/2.0/en/contributing/code.html
to find out how you can contribute patches.


Am 28.10.2011 15:30, schrieb Sandreu:
 Hello,

 I made an increment for file engine system.
 My problem was that in APC cache, the cache is not shared between CLI
 and the web app... then I did that with fileEngine using flock... it's
 not workink on windows.
why would it not work on windows? I didn't find such a hint on the
flock() docs.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php