twitter / twemproxy

A fast, light-weight proxy for memcached and redis
Apache License 2.0
12.14k stars 2.06k forks source link

parsed unsupported command 'OBJECT' #649

Open steamboatid opened 3 years ago

steamboatid commented 3 years ago

Describe the bug I got these error message when execute $redis->object('encoding', $rkey) from php 8 nc_redis.c:1324 parsed unsupported command 'OBJECT'

To Reproduce

<?php
define('RED_HOST', '127.0.0.1');
define('RED_PORT', 27379); //keydb=7379, redis=6379, php-redis=17379, nutcracker=27379
define('RED_PIPE', true);

$redis = new \Redis();
$redis->connect(RED_HOST, RED_PORT);

$redis->sAddArray('aaa', range(1, 10));
$arr = $redis->sMembers('aaa');
$enc = $redis->object('encoding', 'aaa');

Expected behavior $redis->object will return specified encoding from redis/keydb

Screenshots image

image

Environment OS: Debian 10.10 PHP: 8.0 Twemproxy: 0.5.0 (custom build on Debian)

Additional context --none--

TysonAndre commented 3 years ago

The lack of support for OBJECT is documented at https://github.com/twitter/twemproxy/blob/master/notes/redis.md - I'm not sure what the original reason for it not being supported is (rarely used? inconsistency in having/not having a key?).

It's probably feasible to support it for only known commands with only one key - there's no fragmentation (multiple keys) to worry about it.

127.0.0.1:6379> object encoding value
(nil)
127.0.0.1:6379> object encoding key
"embstr"
127.0.0.1:6379> object encoding key key
(error) ERR Unknown subcommand or wrong number of arguments for 'encoding'. Try OBJECT HELP.
steamboatid commented 3 years ago

in practical use, KEYS OBJECT only support 3 arguments

OBJECT REFCOUNT <key>
OBJECT ENCODING <key>
OBJECT IDLETIME <key>
OBJECT FREQ <key>

so for the time being, that's enough to support 3 arguments only