Skip to content

Commit 5b0e15d

Browse files
committed
Moving names around, and the big fix.... Weirdness with the session handler, adding ttl to time was causing weird stuff to happen. Solves issue #13
1 parent e0a14af commit 5b0e15d

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/Aequasi/Bundle/CacheBundle/DependencyInjection/Builder/ServiceBuilder.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ private function buildService($typeId, $name, array $instance)
7474
private function prepareCacheClass(Definition $service, $name, array $instance)
7575
{
7676
$type = $instance['type'];
77-
$id = sprintf("%s.instance.%s.%s_instance", $this->getAlias(), $name, $type);
77+
$id = sprintf("%s.instance.%s.cache_instance", $this->getAlias(), $name);
7878
$cache = null;
7979

8080
switch ($type) {
8181
case 'memcache':
8282
if (empty($instance['id'])) {
8383
$cache = new Definition('Memcache');
84-
$cache->setPublic(false);
84+
//$cache->setPublic(false);
8585
foreach ($instance['hosts'] as $config) {
8686
$host = empty($config['host']) ? 'localhost' : $config['host'];
8787
$port = empty($config['port']) ? 11211 : $config['port'];
@@ -99,11 +99,12 @@ private function prepareCacheClass(Definition $service, $name, array $instance)
9999
case 'memcached':
100100
if (empty($instance['id'])) {
101101
$cache = new Definition('Memcached');
102+
//$cache->setPublic(false);
103+
102104
if ($instance['persistent']) {
103105
$cache->setArguments(array(serialize($instance['hosts'])));
104106
}
105107

106-
$cache->setPublic(false);
107108
foreach ($instance['hosts'] as $config) {
108109
$host = is_null($config['host']) ? 'localhost' : $config['host'];
109110
$port = is_null($config['port']) ? 11211 : $config['port'];
@@ -121,7 +122,8 @@ private function prepareCacheClass(Definition $service, $name, array $instance)
121122
case 'redis':
122123
if (empty($instance['id'])) {
123124
$cache = new Definition('Redis');
124-
$cache->setPublic(false);
125+
//$cache->setPublic(false);
126+
125127
foreach ($instance['hosts'] as $config) {
126128
$host = empty($config['host']) ? 'localhost' : $config['host'];
127129
$port = empty($config['port']) ? 6379 : $config['port'];

src/Aequasi/Bundle/CacheBundle/DependencyInjection/Compiler/SessionSupportCompilerPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ private function enableSessionSupport(array $config)
6666
$this->container->setDefinition(sprintf('%s.session_handler', $this->getAlias()), $definition);
6767
$this->container->setAlias('cache.session_handler', sprintf('%s.session_handler', $this->getAlias()));
6868

69-
$this->container->setAlias('session.handler', $this->getAlias() . '.session_handler');
69+
$this->container->setAlias('session.handler', 'cache.session_handler');
7070
}
7171
}

src/Aequasi/Bundle/CacheBundle/Service/CacheService.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private function timeCall( $name, $arguments )
100100
*
101101
* @return mixed The cached data or FALSE, if no cache entry exists for the given id.
102102
*/
103-
function fetch( $id )
103+
public function fetch( $id )
104104
{
105105
if ($this->isLogging()) {
106106
$call = $this->timeCall( 'fetch', array( $id ) );
@@ -122,7 +122,7 @@ function fetch( $id )
122122
*
123123
* @return boolean TRUE if a cache entry exists for the given cache id, FALSE otherwise.
124124
*/
125-
function contains( $id )
125+
public function contains( $id )
126126
{
127127
if ($this->isLogging()) {
128128
$call = $this->timeCall( 'contains', array( $id ) );
@@ -144,7 +144,7 @@ function contains( $id )
144144
*
145145
* @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise.
146146
*/
147-
function save( $id, $data, $lifeTime = self::NO_EXPIRE )
147+
public function save( $id, $data, $lifeTime = self::NO_EXPIRE )
148148
{
149149
if ($this->isLogging()) {
150150
$call = $this->timeCall( 'save', array( $id, $data, $lifeTime ) );
@@ -164,7 +164,7 @@ function save( $id, $data, $lifeTime = self::NO_EXPIRE )
164164
*
165165
* @return boolean TRUE if the cache entry was successfully deleted, FALSE otherwise.
166166
*/
167-
function delete( $id )
167+
public function delete( $id )
168168
{
169169
if ($this->isLogging()) {
170170
$call = $this->timeCall( 'delete', array( $id ) );
@@ -248,7 +248,7 @@ private function getDataFromPayload( $payload )
248248
*
249249
* @return array|null An associative array with server's statistics if available, NULL otherwise.
250250
*/
251-
function getStats()
251+
public function getStats()
252252
{
253253
return $this->cache->getStats();
254254
}
@@ -292,4 +292,4 @@ public function getCalls()
292292
{
293293
return $this->calls;
294294
}
295-
}
295+
}

src/Aequasi/Bundle/CacheBundle/Session/SessionHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct( Cache $cache, array $options = array() )
4949
$this->cache = $cache;
5050

5151
$this->ttl = isset( $options[ 'cookie_lifetime' ] ) ? (int)$options[ 'cookie_lifetime' ] : 86400;
52-
$this->prefix = isset( $options[ 'prefix' ] ) ? $options[ 'prefix' ] : 'sf2s';
52+
$this->prefix = isset( $options[ 'prefix' ] ) ? $options[ 'prefix' ] : 'sf2ses_';
5353
}
5454

5555
/**
@@ -81,7 +81,7 @@ public function read( $sessionId )
8181
*/
8282
public function write( $sessionId, $data )
8383
{
84-
return $this->cache->save( $this->prefix . $sessionId, $data, time() + $this->ttl );
84+
return $this->cache->save( $this->prefix . $sessionId, $data, $this->ttl );
8585
}
8686

8787
/**

0 commit comments

Comments
 (0)