jdp / redisent Goto Github PK
View Code? Open in Web Editor NEWa no-nonsense Redis client for PHP
Home Page: http://jdp.github.com/redisent/
License: ISC License
a no-nonsense Redis client for PHP
Home Page: http://jdp.github.com/redisent/
License: ISC License
Could you check if CRLF is defined as a constant before setting it?
The FuelPHP framework already defines this constant, so our users can not use redisent at the moment.
Hello,
Can we have Redis cluster support also with it ? It will used in scale . Thank You
If CRLF has already been defined, then
define('CRLF', sprintf('%s%s', chr(13), chr(10)));
in Redisent.php will cause an error and stop execution.
if( !defined('CRLF') ) define('CRLF', sprintf('%s%s', chr(13), chr(10)));
This fixes it, and it seems to work but this may be system / code dependant.
for ($written = 0; $written < strlen($command); $written += $fwrite) {
$fwrite = fwrite($this->__sock, substr($command, $written));
if ($fwrite === FALSE) {
throw new Exception('Failed to write entire command to stream');
}
}
On broken pipe fwrite
returns 0 and it loops for ever.
I think adding sortable sets support from Redis 1.2
Adding 'ZADD', 'ZREM' to $bulk_cmds worked for me (just using ZADD and ZRANGE currently)
Cheers!
It was possible to call sort command like this in older versions:
$redis->sort('set_name limit 0 10 desc');
It doesn't work anymore so you have to call sort method like this:
$redis->sort('set_name', 'limit', '0', '10', 'desc');
Is it possible to do something with that?
Hi
I think it's a bit of a bug. When the redis server is down
$this->__sock = fsockopen($host, $port, $errno, $errstr);
PHP displays a warning before the exception is thrown.
Warning: fsockopen() [function.fsockopen]: unable to connect to localhost:6379 (Connection refused) in ./lib/redisent/redisent.php on line 47
I think some checking if the socket exists would help or at least something like this:
$this->__sock = @fsockopen($host, $port, $errno, $errstr);
Which is not the bes solition but it works :)
Cheers!
Hello Justin,
I am not sending a pull request yet.. as these are some major modifications, please look at our branch (https://github.com/AF83/redisent/tree/redis2) to see if you would be interested in merging it. If so I will merge in your latest changes so you'll have less work.
Ori
I'm interested in adding support for adding a socket connect timeout and I wanted to get some feedback on your preferred approach for this.
Setting the timeout is relatively straightforward (just one more parameter to fsockopen), my question is really about the best way to pass in the timeout, it could either be done as an extra parameter on the constructor:
<?php
$redis = new redisent\Redis('redis://localhost:6379', $timeout = 2);
Or it could be made a query string parameter on the dsn:
<?php
$redis = new redisent\Redis('redis://localhost:6379?timeout=2');
I'm happy to code it up myself, just let me know which option you prefer.
Its not so much an issue in your code but if you compile it in HipHop, the sprintf fails if a string starts with \x00
eg
$args[0] = "\x00\x5f";
$args[1] = "\x81\x77\x97\xa1\x8d\x4a\x25\xc1\x83\x71\xa0\x50\x02\xb7";
$name = 'hget';
If you replace the array_map with this, it works
$command = '*' . intval(count($args)) . CRLF. implode(array_map(function($arg) {
return '$' . intval(strlen($arg)) . CRLF . $arg . CRLF;
}, $args)). . CRLF ;
How do I use HMSET with redisent?
I'm trying:
$array= array("IP", $IP, "ROOMNAME", $room);
$redis->hmset("new_room", $array);
But I'm receiving an error:
PHP Fatal error: Uncaught exception 'redisent\\RedisException' with message 'Protocol error: invalid bulk length' (...)
Redisent should bind and use hiredis when the option is available.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.