Hi,

Is it possible to add a config file option (which is disabled by default) to get the values along with the keys for the PSUBSCRIBE key space notifications? I understand that the data blob can be very large, but there are also use cases where the data is not large enough to cause any instabilities. If the user can configure this option, then it would be really useful and if the user (as in developer using redis) chooses to shoot themselves in the foot, no one can prevent them.

Thanks.

Comment From: ljluestc


void notifyKeyspaceEvent(int type, const char *event, robj *key, robj *val) {
    // ... existing code ...

    if (server.notify_keyspace_with_value) {
        // Serialize the value into a string or some format suitable for transmission
        sds value_str = serializeValueForNotification(val);
        publishMessage(keyspace_channel, event, key, value_str);
        sdsfree(value_str);
    } else {
        publishMessage(keyspace_channel, event, key, NULL);
    }

    // ... rest of the function ...
}

// Helper function to serialize value (pseudo-code as actual implementation would depend on serialization method)
sds serializeValueForNotification(robj *val) {
    sds result = sdsempty();
    if (val->type == REDIS_STRING) {
        result = sdscatlen(result, val->ptr, sdslen(val->ptr));
    } else if (val->type == REDIS_LIST) {
        // ... handle other types similarly ...
    }
    return result;
}