Skip to content

Can expiringmap provide a function to obtain multiple keys? #86

@wp973

Description

@wp973

like caffeine getAllPresent

 Map<K, V> getAllPresent(Iterable<? extends K> keys)

I tried to write a method, is this method feasible?🤔

  public List<V> getAllPresent(List<K> keys) {

    List<V> result = Collections.emptyList();

    if (keys != null && !keys.isEmpty()) {
      result = new ArrayList<V>(keys.size());

      for (K key : keys) {
        V value = get(key);

        if (value != null) {
          result.add(get(key));
        }
      }

    }

    return result;
  }

Thanks for your reply.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions