当我在 laravel 5 上使用缓存时,它不断给我一个错误未找到类'App\Http\Controllers\Cache'
<?php namespace App\Http\Controllers;
class ChannelController extends Controller {
public function popular()
{
Cache::put('test','test value',10);
}
}
这只是一个简单的缓存,但仍然不起作用。顺便说一句,我的缓存配置设置为 memcached - 它在 laravel 4.2 上运行良好,但在 laravel 5 上则不然。
最佳答案
缓存不在您的应用命名空间内,您可以:
<?php namespace App\Http\Controllers;
use \Cache;
class ChannelController extends Controller {
然后您可以在整个类(class)中使用Cache
。或者,您可以将 \
添加到现有行中:
\Cache::put('test','test value',10);
关于php - Laravel 5 类 'App\Http\Controllers\Cache' 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29131808/