Last active
August 29, 2015 14:08
-
-
Save Majkl578/904927f5b5aa8f805abc to your computer and use it in GitHub Desktop.
Nette sessions + custom save path and automatic GC, IT WORKS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"nette/http": "2.2.*" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
run() { | |
ab -n $1 -c $2 http://local/sessions-test/test.php > /dev/null | |
} | |
files() { | |
echo `ls -1 data/ | wc -l` | |
} | |
run 100 20 | |
files | |
sleep 2 | |
run 100 20 | |
files | |
sleep 2 | |
run 100 20 | |
files | |
sleep 2 | |
run 100 20 | |
files | |
sleep 5 | |
run 1 1 | |
files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require __DIR__ . '/vendor/autoload.php'; | |
//$before = iterator_to_array(new FilesystemIterator(__DIR__ . '/data', FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS)); | |
$session = new Nette\Http\Session((new Nette\Http\RequestFactory)->createHttpRequest(), new Nette\Http\Response()); | |
$session->setName('blablasesstest'); | |
$session->setSavePath(__DIR__ . '/data'); | |
$session->setExpiration('+ 3 seconds'); | |
$session->setOptions([ | |
'gc_probability' => 100, | |
'gc_divisor' => '100', | |
]); | |
$session->start(); | |
$session->getSection('test')->foo = 'bar'; | |
$session->close(); | |
//$after = iterator_to_array(new FilesystemIterator(__DIR__ . '/data', FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS)); | |
//echo 'Before:', PHP_EOL; | |
//var_dump($before); | |
//echo 'After:', PHP_EOL; | |
//var_dump($after); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment