php/redis

Hello everyone,

I am really new to programming in general and to php in particular. I am trying to implement what looks like a very simple code for redisent with php. But when I run redis 127.0.0.1:6379> keys *2 (from my ubuntu terminal), I keep getting empty set. Here is the code (which I found on this wenbsite: https://github.com/jdp/redisent):

require_once ‘redisent/Redis.php’;
$redis = new redisent\Redis(‘redis://localhost’);
$redis->set(‘awesome’, ‘absolutely’);
echo "Is Redisent awesome? ", $redis->get(‘awesome’), “\n”;

I suspect the problem to be the location of redis.php. It is in the root directory of apache2 so that when I type in my browser http://localhost/redis.php it could execute, but it is just showing me the original php code. Any help with some explanation please.

Since the code doesn’t execute it seems like you haven’t got php installed, or haven’t set up apache properly.

Run this in terminal

php -v

Hello,

PHP is isntalled, I jsut checked. Thank you for your response though!

Does the file start with this?

<?php

Hello,

No it did not and that was the problem. Thank you so much for your help :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service