.NET Client Documentation
5.3.0
Search Results for

    Show / Hide Table of Contents

    ReplaceAsync Method

    ReplaceAsync(TKey, TValue)

    Updates an entry if it exists.

    Declaration
    Task<TValue> ReplaceAsync(TKey key, TValue newValue)
    Parameters
    TKey key

    A key.

    TValue newValue

    The new value.

    Returns
    Task<TValue>

    The existing value, if any; otherwise default(TValue).

    Remarks

    If an existing entry with the specified key is found, then its value is updated with the new value, and the existing value is returned. Otherwise, nothing happens.

    This methods interacts with the server-side MapStore. If no value for the specified key is found in memory, MapLoader.load(...) is invoked to try to load the value from the MapStore backing the map, if any. If write-through persistence is configured, before the value is stored in memory, MapStore.store is invoked to write the value to the store.

    ReplaceAsync(TKey, TValue, TValue)

    Updates an entry if it exists, and its value is equal to comparisonValue.

    Declaration
    Task<bool> ReplaceAsync(TKey key, TValue newValue, TValue comparisonValue)
    Parameters
    TKey key

    A key.

    TValue newValue

    The new value.

    TValue comparisonValue

    The value that is compared with the value of the entry.

    Returns
    Task<bool>

    true if the entry was updated; otherwise false.

    Remarks

    If an existing entry with the specified key and expected value is found, then its value is updated with the new value. Otherwise, nothing happens.

    This methods interacts with the server-side MapStore. If no value for the specified key is found in memory, MapLoader.load(...) is invoked to try to load the value from the MapStore backing the map, if any. If write-through persistence is configured, before the value is stored in memory, MapStore.store is invoked to write the value to the store.

    In This Article
    Back to top Copyright © 2010-2023 Hazelcast, Inc. All rights reserved.
    Generated by DocFX.