You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Prasad Bhalerao <pr...@gmail.com> on 2018/05/14 13:47:58 UTC

put vs putAll

Hi,

Does putAll perform better than put method if the data being pushed to the
cache is going to land up on same node from where it is being pushed?

1)   try (Transaction transaction = transactions.txStart()) {
      for (Data data : datas) {
        ipv4DataCache.put(data.getKey(), data);
      }
      transaction.commit();
    }



2)  try (Transaction transaction = transactions.txStart()) {
        ipv4DataCache.putAll(map);
        transaction.commit();
    }

Does code 2 performs better than code 1?


Thanks,
Prasad

Re: put vs putAll

Posted by Dmitriy Govorukhin <dm...@gmail.com>.
Prasad,

PutAll more effective in many cases, because transaction obtains locks for
keysSet in the batch.
Each put will be produced a call for obtain lock for the appropriate key,
in general, it more slowly.

On Mon, May 14, 2018 at 4:47 PM, Prasad Bhalerao <
prasadbhalerao1983@gmail.com> wrote:

> Hi,
>
> Does putAll perform better than put method if the data being pushed to the
> cache is going to land up on same node from where it is being pushed?
>
> 1)   try (Transaction transaction = transactions.txStart()) {
>       for (Data data : datas) {
>         ipv4DataCache.put(data.getKey(), data);
>       }
>       transaction.commit();
>     }
>
>
>
> 2)  try (Transaction transaction = transactions.txStart()) {
>         ipv4DataCache.putAll(map);
>         transaction.commit();
>     }
>
> Does code 2 performs better than code 1?
>
>
> Thanks,
> Prasad
>