I found solution regarding slam problem with cache (I've mentioned it before: http://forum.phalconphp.com/discussion/1873/cache-and-process-synchronisation).

There is new extension that provides elegant and cross-platform mutex solution:


Please incorporate this into Phalcon as optional way to synchronise cache-calls, so the slam problem can be avoided.

I think it could work in this way:

$cache->get($cacheKey, $optionalMutexTimeout);

$cache->save($cacheKey, $cacheItem, $optionalMutexTimeout);

If $optionalMutexTimeout is not null, it means we use synchronisation if available.

In case of two or more threads want to create item, only one is creating it and rest just waiting until item is created and lock released, after that they're getting newly created item. The same scenario applies to Readers while item is created.