profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/michael-grunder/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Michael Grunder michael-grunder Seattle, WA http://www.phpredis.org C, Rust, PHP and Redis dev

michael-grunder/muslbuild-example 4

Quick example building rdkafka-sys with the rust-musl-builder

michael-grunder/phpredis 3

A PHP extension for Redis

michael-grunder/async-scoped 1

A scope for async_std to spawn non-static futures

michael-grunder/csv-split-rs 1

A Rust port of my C based csv-split utility

michael-grunder/iou 1

Rust interface to io_uring

michael-grunder/iou-example-project 1

Testing IoUring interface.

michael-grunder/redis-mon-demo 1

async await demo redis monitor

michael-grunder/bfs 0

A breadth-first version of the UNIX find command

michael-grunder/blog 0

Our open source benchmarks and code samples

pull request commentphpredis/phpredis

Update sentinel.markdown

Merged, thanks!

feverxai

comment created time in 18 hours

push eventphpredis/phpredis

Naphat Deepar

commit sha 61416794adb09d4b13b8ec0209dd3b91ae077321

Update sentinel.markdown add document about connect sentinel with authentication

view details

Michael Grunder

commit sha d183694f3246c121f4e727eb63aad43144817658

Merge pull request #2011 from feverxai/patch-1 Update sentinel.markdown

view details

push time in 18 hours

PR merged phpredis/phpredis

Update sentinel.markdown

add document about connect sentinel with authentication

+2 -0

0 comment

1 changed file

feverxai

pr closed time in 18 hours

PullRequestReviewEvent
PullRequestReviewEvent

issue commentredis/hiredis

Reusing an async context with libevent

I need to create a more robust async example because async programming is tricky and requires a very different mental model. Basically in async everything is handled with watchers and callbacks.

Here is a quick and dirty Gist that signals a "SET" watcher from a different thread

In this small example, I read a string from stdin and then signal that I want to SET a key with that string, although in a real program you'd want to use a thread-safe queue to pass the message payload.

I also found these examples, which may be of some use

picanumber

comment created time in 2 days

issue commentredis/hiredis

Reusing an async context with libevent

Hi @picanumber,

I'm not sure I completely understand your use-case, but you certainly don't need to call redisAsyncDisconnect from the command callbacks. That's just what's being done in the simple sample programs.

Typically with async and an event loop, the loop would be long-running (often for the total length of the program), and you would attach various timers, IO, or other watchers to handle the actual program logic.

Is an asynchronous context supposed to "die" after the execution of a single command? If not how can I reuse it, since not killing the connection causes the program to loop forever around event_base_dispatch?

You can use the REDIS_NO_AUTO_FREE to stop hiredis from cleaning up the connection on disconnect, but I'm not sure that's really what you would want. What kind of program are you trying to make. I can try to help outline how you might go about it via async hiredis.

picanumber

comment created time in 3 days

issue commentphpredis/phpredis

No equivlent mehtod to redis ZRANDMEMBER

Thanks for the report, we'll get it implemented.

As a workaround you can use rawCommand:

<?php

$redis = new Redis;
$redis->connect('localhost', 6379);

echo "No arguments:\n";
var_dump($redis->rawCommand('ZRANDMEMBER', 'zs'));

echo "\nWithscores:\n";
var_dump($redis->rawCommand('ZRANDMEMBER', 'zs', 1, 'WITHSCORES'));

?>
apuppy

comment created time in 10 days

pull request commentphpredis/phpredis

add saddInt and saddIntArray

Thanks for the PR but I think we're miscommunication.

This PR doesn't actually do what you want it to do. It still sends a SADD command to Redis only sending "long" values in the command rather than strings, which isn't actually supported in the RESP protocol. Arguments are always bulk strings (which can be converted as Redis processes them).

Even in commands like LRANGE <start> <end> the <start> and <end> are delivered as strings:

*3\r\n
$6\r\n
LRANGE\r\n
$1\r\n
0\r\n
$2\r\n
-1\r\n

If you want Redis or KeyDB to never reencode as a hash table, just set the config value to a very large number. Again, this will become a performance problem eventually, however.

steamboatid

comment created time in 25 days

issue commentphpredis/phpredis

SETS stored as intset, avoid hashtable

I don't see this behavior.

If I start an instance of KeyDB like so:

❯ src/keydb-server --port 10000 --save "" --set-max-intset-entries 10000

And then run my little test script, I get the output I would expect (intset until the set has more than 10000 elements):

❯ php /tmp/intset.php
Max intset values: 10000
'myset' cardinality: 10000, encoding: intset
'myset' cardinality: 10001, encoding: hashtable

Also, KeyDB just tests if the input string can be converted to a long

You may be running into an issue where a set is already a HashTable since KeyDB and Redis don't convert them back AFAIK.

steamboatid

comment created time in a month

push eventphpredis/phpredis

dengliming

commit sha d7a6eda7d039791df441b176c091ffc2a33d7720

Update README.markdown

view details

Michael Grunder

commit sha ed532e9afcfe3c14ff9f75a509fa1160aa1fbbcc

Merge pull request #1959 from dengliming/patch-1 Update README.markdown

view details

push time in a month

issue closedphpredis/phpredis

Document error

Expected behaviour

$redis->mset(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']); $redis->exists(['foo', 'bar', 'baz']); /* 3 / $redis->exists('foo', 'bar', 'baz'); / 3 */

Actual behaviour

$redis->mset(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']); $redis->exists(['foo', 'bar', 'baz]); /* 3 / $redis->exists('foo', 'bar', 'baz'); / 3 */

I've checked

  • [x] There is no similar issue from other users
  • [x] Issue isn't fixed in develop branch

There is a problem with the exists method code in the document.The lack of '

image

closed time in a month

tim1116

push eventphpredis/phpredis

Poplary

commit sha b3e5a7e27b652e0672ed03139ff7538be7699af4

Fixed README, add the missing single quote mark.

view details

Michael Grunder

commit sha fac5f43ecc27f5cb6f4c3b971569c30172f1b084

Merge pull request #1926 from poplary/poplary-patch-fix-README Fixed README, add the missing single quote mark.

view details

push time in a month

push eventphpredis/phpredis

Maxime CORNET

commit sha 5f8b0a7a69d3ae71929deb83ea0f0c6bf04ed9fa

Add json serializer in documentation

view details

Michael Grunder

commit sha 918604fa8c5cb50af158f7cc9bc2724390157710

Merge pull request #1967 from xElysioN/add-missing-serialization-type Add json serializer in documentation

view details

push time in a month

PR merged phpredis/phpredis

Add json serializer in documentation

Add the JSON serializer in the documentation

+2 -1

0 comment

1 changed file

xElysioN

pr closed time in a month

Pull request review commentphpredis/phpredis

Update INSTALL.markdown

 pickle install redis To build this extension for the sources tree:  ~~~+git clone https://github.com/phpredis/phpredis.git+cd phpredis phpize ./configure [--enable-redis-igbinary] [--enable-redis-msgpack] [--enable-redis-lzf [--with-liblzf[=DIR]]] [--enable-redis-zstd] make && make install+cd .. && rm -r phpredis

I think remove this line and I'll merge it.

ttodua

comment created time in a month

PullRequestReviewEvent

issue closedphpredis/phpredis

sAdd return 0, if value exists

Expected behaviour

return false like in sAdd docblock

* @return int|bool The number of elements added to the set. * If this value is already in the set, FALSE is returned

Actual behaviour

return 0

I'm seeing this behaviour on

  • OS: MacOS 11.5.2
  • Redis: 6.0.6
  • PHP: 8.0.9
  • phpredis: 5.3.4

Steps to reproduce, backtrace or example script

$result = $redis->sAdd('users', 'garry'); // $result is 1

$result = $redis->sAdd('users', 'garry'); // $result is 0

I've checked

  • [x] There is no similar issue from other users
  • [x] Issue isn't fixed in develop branch

closed time in a month

Ridzhi

issue commentphpredis/phpredis

sAdd return 0, if value exists

I removed the erroneous bit about returning FALSE.

First time I used the GitHub editor directly too, which is cool.

Ridzhi

comment created time in a month

push eventphpredis/phpredis

Michael Grunder

commit sha edbf520ca41d44c7b3c87350f986f80a040b4409

Fix sAdd documentation (see #2002)

view details

push time in a month

issue closedphpredis/phpredis

SETS stored as intset, avoid hashtable

Expected behaviour

KeyDB (or maybe REDIS) store SETS as intset if inputed with integer values. If possible, please add dedicated method to phpredis, named as sAddInt and sAddIntArray to utilize intset

FYI, I store about 50K items in SETS. I believe it will reduce the memory needed, if we can utilize intset SETS at Redis or KeyDB

Actual behaviour

KeyDB always save SETS as hashtable.

I'm seeing this behaviour on

  • OS: Debian 10
  • Redis: keydb 5.1.1
  • PHP: 8.0.9
  • phpredis:

Steps to reproduce, backtrace or example script

$serializer = array( 'igbinary' => Redis::SERIALIZER_IGBINARY, 'php' => Redis::SERIALIZER_PHP, 'none' => Redis::SERIALIZER_NONE, );

foreach ($serializer as $ser_idx => $ser_val) { $tkey = 'tkey' . $ser_idx . time(); $redis->setOption(Redis::OPT_SERIALIZER, $ser_val); $redis->sAddArray($tkey, range(1, 10)); $arr = $redis->sMembers($tkey); $enc = $redis->object('encoding', $tkey); printf("Serializer=%9s, Encoding= %s \n", $ser_idx, $enc); }

I've checked

  • [x] There is no similar issue from other users
  • [x] Issue isn't fixed in develop branch

closed time in a month

steamboatid

issue commentphpredis/phpredis

SETS stored as intset, avoid hashtable

Closing this, since it's not a bug in PhpRedis (or even under our control) but feel free to ask any other questions you have.

steamboatid

comment created time in a month

issue commentphpredis/phpredis

SETS stored as intset, avoid hashtable

This isn't under phpredis' control.

There is a redis-server configuration value called set-max-intset-entries which determines how large sets can be before they are converted into a hash table.

This program illustrates that:

<?php

function printSetInfo($redis, $key) {
    echo "'$key' cardinality: " . $redis->sCard('myset') . ', encoding: ' . $redis->object('encoding', 'myset') . "\n";
}

$redis = new Redis;
$redis->connect('localhost', 6379);

$max = $redis->config('get', 'set-max-intset-entries');
$max = $max['set-max-intset-entries'];

echo "Max intset values: $max\n";

$redis->del('myset');
for ($i = 0; $i < $max; $i++) {
    $redis->sAdd('myset', $i);
}

// Set has <= set-max-intset-entries, Will be encoded as an 'intset'
printSetInfo($redis, 'myset');

// Adding another item causes Redis to convert the set to a 'hashtable'
$redis->sAdd('myset', $i);
printSetInfo($redis, 'myset');

You can likely increase that setting much higher than 512 but you will need to test whether it works in your use-case. The intset encoding is much more memory efficient but has O(N) insert performance which could present a problem when the sets get much larger.

steamboatid

comment created time in a month

pull request commentredis/hiredis

Don't leak memory if an invalid type is set

Merged, thanks!

rouzier

comment created time in a month

push eventredis/hiredis

rouzier

commit sha 2d9d77518d012a54ae34f9822e4b4d19823c4b75

Don't leak memory if an invalid type is set (#906) Co-authored-by: James Rouzier <jrouzier@inverse.ca>

view details

push time in a month

PR merged redis/hiredis

Reviewers
Don't leak memory if an invalid type is set
+1 -1

2 comments

1 changed file

rouzier

pr closed time in a month

issue closedredis/hiredis

SSL AsyncConnection

I'm using an older version of hiredis with ssl and async, but I'm unsure where is correct place to call redisSecureConnection, as it always return REDIS_OK even if redis-server is down. I've tried immediately after creating the redisAsyncContext, in the onConnectCallback, and finally before sending a redisAsyncCommand. Since it's always return REDIS_OK, there is no way to catch errors until a command is sent, but at that point it's difficult to figure out if redis-server was down or if it was an error in the command.

This does not happen for synchronous connection, redisSecureConnection will return REDIS_ERR if redis-server is down.

Thanks for the help!

loop = aeCreateEventLoop(64);

redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379);
redisSecureConnection(&c.c, ....) // always return REDIS_OK
redisAeAttach(loop, c);
redisAsyncSetConnectCallback(c,connectCallback);
redisAsyncSetDisconnectCallback(c,disconnectCallback);
redisAsyncCommand(...);

closed time in a month

TonySalesforce

issue commentredis/hiredis

SSL AsyncConnection

Going to close this as it's not a bug with hiredis but feel free to ask more questions if you have them and I'll do my best to answer.

TonySalesforce

comment created time in a month