Save Session in Memcached in zend

I am working on a zf project. Currently session is saved in Mongo DB. My task is to change the logic to save session in Memcached instead.

I implemented a factory for (\Zend\Session\SaveHandler\Cache)

public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
$cache = StorageFactory::factory([
‘adapter’ => [
‘name’ => ‘Memcached’,
‘options’ => [
‘servers’ => [
‘compression’ => true,

    return new \Zend\Session\SaveHandler\Cache($cache);

But I receive this Warning

Warning: session_write_close(): Cannot call session save handler in a recursive manner

Does any one has an idea to fix it?