tedis icon indicating copy to clipboard operation
tedis copied to clipboard

Why does `mget` has two parameters?

Open metehus opened this issue 3 years ago • 0 comments

The mget method has two parameters:

  /**
   * Returns the values of all specified keys. For every key that does not hold a string value or does not
   * exist, the special value nil is returned. Because of this, the operation never fails.
   *
   * @param key The key.
   * @param keys The other key.
   * @returns List of values at the specified keys.
   */
  public mget(key: string, ...keys: string[]) {
    return this.command<Array<string | number | null>>("MGET", key, ...keys);
  }

But shouldn't it be only one? this just seems weird and is very bad to use this method, having to do something like this:

  public async getManyObjects (keys: string[]) {
    return tedisClient.mget('_', ...keys).then(list => list.slice(1))
  }

Suggested behaviour

I would suggest to remove or concat the first key parameter, so we could use it like this:

  public async getManyObjects (keys: string[]) {
    return tedisClient.mget(...keys)
  }

metehus avatar Jul 07 '22 04:07 metehus