package com.elab.redis.utils;

import org.springframework.data.redis.serializer.StringRedisSerializer;

public class StringSerializerUtils {

    private static final byte[][] EMPTY_2D_BYTE_ARRAY = new byte[0][];

    private static StringRedisSerializer serializer = new StringRedisSerializer();

    public static byte[] serialize(String data) {
        return serializer.serialize(data);
    }

    public static byte[][] serializeMulti(String... keys) {

        if (keys == null) {
            return EMPTY_2D_BYTE_ARRAY;
        }

        byte[][] ret = new byte[keys.length][];

        for (int i = 0; i < ret.length; i++) {
            ret[i] = serializer.serialize(keys[i]);
        }

        return ret;
    }
}
