I'm using PHP with PHPRedis to connect to Redis.
This works fine
$redis = new Redis();
$redis->connect('localhost', 6379);
$total = $redis->get('total');
Let's say $total is now 1. I then use the Redis client to increment the key 'total' so that it has a value of 2.
But now I want a user to be able to see the new value when they click a button
<script type="text/javascript">
window.onload=function() {
$('#newTotal').click(function (event) {
<?php
$redis = new Redis();
$redis->connect('localhost', 6379);
$total = $redis->get('total');
?>
$("#updated").html("Total is now <?php echo $total; ?>");
});
}
</script>
But this does not give the new value.
How can I connect to get the updated values?