GithubHelp home page GithubHelp logo

tinyredisclient's People

Contributors

ptrofimov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinyredisclient's Issues

How do you use multi and exec with tinyredisclient?

How do you use multi and exec with tinyredisclient? Do you have an example usage?

I've tried the multi and exec... it "works" but i think i need to call the connection too many times...

e.g.
$redis->multi();
$redis->scard('a');
$redis->scard('b');
.
.
$redis->scard('z');

$values=$redis->exec();
but... it doesn't seem to send everything all at once?

I would like to have array of tinyredisclient

e.g. as in predis

$array = new Predis_Client(array(
array('host' => '127.0.0.1','port' => 1000),
array('host' => '127.0.0.1','port' => 1001),
array('host' => '127.0.0.1','port' => 1002),
array('host' => '127.0.0.1','port' => 1003),
array('host' => '127.0.0.1','port' => 1004)
));

how can i make this...

$config = '127.0.0.1:1000';
$item = new TinyRedisClient($config);

to

$config = array('127.0.0.1:1000','127.0.0.1:1001','127.0.0.1:1002');
$item = new TinyRedisClient($config);

this php will be complete and excellent if this feature is added. please help. thanks.

fread fails to return full string (but fgets works)

Data is php serialized string. EG 'a:6:{s:7:"success";b:1;s:5:"total";s:1:"8";s:4:"data";a:8:{i:0;a:17..." etc

Data is 7169 bytes long. Returned as "RESP Bulk String"."

$line = fread($this->getSocket(), $result + 2); // FAILS TO RETURN 7171 bytes

Ask to read 7171 but get back ony 2888 bytes. So php unserialize fails.

Verify no timeout or blocking:

017-12-17 17:10:37
'META'
array (
  'stream_type' => 'tcp_socket/ssl',
  'mode' => 'r+',
  'unread_bytes' => 0,
  'seekable' => false,
  'timed_out' => false,             OK
  'blocked' => true,                OK
  'eof' => false,
)

// This works. I get the full string (7169 bytes)
$line = fgets($this->getSocket());

So now I think this is ok provided I only use it for serialized string (never contain CRLF).

But I dunno why this is necessary.

Support for multiple DBs

It does not seem that there is a way to select a DB, then issue a command:

echo $redisClient->select(2);
echo $redisClient->get('key');

The select does return ok, but the subsequent get request looks for a key in DB 0. It would be nice to be able to specify the DB in the constructor.

Best,
-O

cannot connect to a tile38 server with docker

`
private $_socket;

public function __construct($address, $port)
{
    $this->_socket = stream_socket_client($address.':'.$port);
}

public function __call($method, array $args)
{
    array_unshift($args, $method);

    $cmd = '*' . count($args) . "\r\n";

    foreach ($args as $item) {
        $cmd .= '$' . strlen($item) . "\r\n" . $item . "\r\n";
    }
    fwrite($this->_socket, $cmd);

    return $this->_parseResponse();
}

private function _parseResponse()
{
    $line = fgets($this->_socket);

    list($type, $result) = array($line[0], substr($line, 1, strlen($line) - 3));

    if ($type == '-') // error message
    {
        throw new TinyRedisClient_Exception($result);
    } elseif ($type == '$') // bulk reply
    {
        if ($result == -1)
            $result = null;
        else {
            $line = fread($this->_socket, $result + 2);
            $result = substr($line, 0, strlen($line) - 2);
        }
    } elseif ($type == '*') // multi-bulk reply
    {
        $count = ( int ) $result;
        for ($i = 0, $result = array(); $i < $count; $i++) {
            $result[] = $this->_parseResponse();
        }
    }
    return $result;
}

`
the problem here is that I don't know where the fwrite() function writes my file does it create an actual file or does it write to the stream resource I don't know, when I try this on my local machine it works fine and the command sent to my database but after I moved to docker this line $line = fgets($this->_socket); returns a false which means there is no data has been written or some error happened, I am expecting the written command to the stream

STREAM_CLIENT_PERSISTENT

I found out that if you change line 43 from:

: ($this->socket = stream_socket_client($this->server));

to

: ($this->socket = stream_socket_client($this->server, $errorno, $errorstr, NULL, STREAM_CLIENT_PERSISTENT));

connection will stay alive and it will work much faster in sequential requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.