If anyone has idea of my above question. Any help would really be appreciated. Thanks
No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379] on localhost
0 down vote favorite
I am using LARAVEL 5.2 and developing ADMIN panel and trying to integrate redis on 1.0 in LARAVEL. When i am trying to set set the variable name along with value it prompting an error:
No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]
The configurational changes i made it is given below:
- In config/session.php file i replaced file with redis
('driver' => env('SESSION_DRIVER', 'redis'))
- Under 'aliases' array under config/app.php file REDIS Facades already included
('Redis' => Illuminate\Support\Facades\Redis::class)
-
In .ENV file i replaced file with redis in SESSION_DRIVER variable
-
In database.php file the config for redis server is given below:
'redis' => [ 'cluster' => true,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
]
Below is my Controller code:
namespace App\Http\Controllers\Administrator;
use App\Http\Controllers\Controller;
use Redis;
use Illuminate\Http\Request;
use App\Http\Requests;
class MyController extends Controller {
public function __construct()
{}
public function myProfile(Request $request)
{
$redis = Redis::connection();
$adminName = $request->route('admin_name');
if ( $redis ) { echo 'connection done'; } else { echo 'connection not done'; }
Redis::set('name', $adminName);
echo $redis->get('name');
}
}
Please or to participate in this conversation.