简体   繁体   English

Laravel在哪里存储memcached会话驱动程序的配置?

[英]Where does Laravel store configuration for memcached session driver?

The Laravel docs specify that you can enable memcached as a session handler in app/config/session.php ; Laravel文档指定您可以在app/config/session.php启用memcached作为会话处理app/config/session.php ; however, it does not specify where memcached itself is configured (such as the servers to use). 但是,它没有指定memcached本身的配置位置(例如要使用的服务器)。

I see that you can configure memcached in app/config/cache.php , but I don't know if that's used just for the Cache driver or for the session handler as well. 我看到你可以在app/config/cache.php配置memcached,但我不知道它是否仅用于Cache驱动程序或会话处理程序。

Yes, the config in app/config/cache.php for your cache drivers is used for session driver as well. 是的, app/config/cache.php用于缓存驱动程序的配置也用于会话驱动程序。

Take a look at vendor/laravel/framework/src/Illuminate/Session/SessionManager.php . 看一下vendor/laravel/framework/src/Illuminate/Session/SessionManager.php The method that creates an instance of the Memcached session driver is this one 创建Memcached会话驱动程序实例的方法就是这个

/**
 * Create an instance of the Memcached session driver.
 *
 * @return \Illuminate\Session\Store
 */
protected function createMemcachedDriver()
{
    return $this->createCacheBased('memcached');
}

That method is calling this other method in the same file 该方法在同一文件中调用此其他方法

/**
 * 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'
}

Which is calling this other method in the same file 这是在同一个文件中调用此其他方法

/**
 * 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);
}

There you can see: this->app['cache']->driver($driver) which is actually getting your cache driver from the IoC container 在那里你可以看到: this->app['cache']->driver($driver)实际上从IoC容器中获取你的缓存驱动程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM