Laravel在哪里存储memcached会话驱动程序的配置?
问题描述:
Laravel文档指定您可以在app/config/session.php
中启用memcached作为会话处理程序;但是,它并未指定memcached本身的配置位置(例如要使用的服务器)。Laravel在哪里存储memcached会话驱动程序的配置?
我看到你可以在app/config/cache.php
中配置memcached,但我不知道它是否仅用于缓存驱动程序或会话处理程序。
答
是的,您的缓存驱动程序的app/config/cache.php
中的配置也用于会话驱动程序。
看看vendor/laravel/framework/src/Illuminate/Session/SessionManager.php
。创建Memcached的会话驱动程序的实例的方法是这样的一个
/**
* Create an instance of the Memcached session driver.
*
* @return \Illuminate\Session\Store
*/
protected function createMemcachedDriver()
{
return $this->createCacheBased('memcached');
}
该方法是在同一个文件调用此其他方法
/**
* Create an instance of a cache driven driver.
*
* @param string $driver
* @return \Illuminate\Session\Store
*/
protected function createCacheBased($driver)
{
return $this->buildSession($this->createCacheHandler($driver)); //$driver = 'memcached'
}
这是调用同一个文件
这个其他方法/**
* Create the cache based session handler instance.
*
* @param string $driver
* @return \Illuminate\Session\CacheBasedSessionHandler
*/
protected function createCacheHandler($driver)
{
$minutes = $this->app['config']['session.lifetime'];
return new CacheBasedSessionHandler($this->app['cache']->driver($driver), $minutes);
}
那里你可以看到:this->app['cache']->driver($driver)
这实际上是从IoC容器让您的高速缓存驱动器
谢谢。如果文档提到这一点,这将是非常好的。 :-) – ScottSB 2014-09-12 13:11:20