Interface CustomDataStorage


  • public interface CustomDataStorage
    Holds custom data values
    Since:
    5.1
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  CustomDataStorage.ConflictResolution
      Controls the conflicts resolution during the flush operation when in-memory data is being stored into the underlying persistent storage.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void clear()
      Clears data in custom data storage.
      void dispose()
      Disposes (destroys) this custom data storage.
      void flush()
      Flushes data to the persistent storage immediately, otherwise flush is performed automatically with some delay.
      void flush​(CustomDataStorage.ConflictResolution conflictResolutionMode)
      Flushes data to the persistent storage immediately with the specified conflict resolution mode.
      java.util.Date getDataLoadTime()
      For a storage whose values have been loaded from the database returns the timestamp when the data was loaded.
      java.lang.String getValue​(java.lang.String key)
      Returns value stored for the specified key
      java.util.Map<java.lang.String,​java.lang.String> getValues()
      Retrieves values from the storage
      boolean isDirty()  
      void putValue​(java.lang.String key, java.lang.String value)
      Puts specified value into the storage.
      void putValues​(java.util.Map<java.lang.String,​java.lang.String> data)
      Puts values into the storage but does not flush the data yet, note that existing data will be completely overwritten.
      void putValuesAndFlush​(java.util.Map<java.lang.String,​java.lang.String> data)
      Same as putValues(Map) but if storage is not created yet, then the method ensures that the storage will be created with the provided data so that other processes could see it's data immediately.
      void refresh()
      Refreshes data from the underlying storage
      void scheduleFlush()
      Performs flush of data asynchronously in a separate thread CustomDataStorage.ConflictResolution.IGNORE_OURS mode is used for the conflict resolution.
      void updateValues​(java.util.Map<java.lang.String,​java.lang.String> newOrChangedValues, java.util.Set<java.lang.String> removedKeys)
      Puts values from newOrChangedValues map to the storage and removes keys provided via removedKeys set.
    • Method Detail

      • putValues

        void putValues​(@NotNull
                       java.util.Map<java.lang.String,​java.lang.String> data)
        Puts values into the storage but does not flush the data yet, note that existing data will be completely overwritten. If this is a new storage which is not yet flushed on disk or in database, then an empty record for this storage will be allocated and will become visible to other processes. But another process will see the storage with empty map of data until the process which created the storage flushes it.
        Parameters:
        data - custom data to put into the storage
      • updateValues

        void updateValues​(@NotNull
                          java.util.Map<java.lang.String,​java.lang.String> newOrChangedValues,
                          @NotNull
                          java.util.Set<java.lang.String> removedKeys)
        Puts values from newOrChangedValues map to the storage and removes keys provided via removedKeys set. If removedKeys and newOrChangedValues map has the same key, then the value from newOrChangedValues will be stored and key won't be removed. If newOrChangedValues has null value for some key, then an exception will be thrown.
        Parameters:
        newOrChangedValues - new values to put in the storage
        removedKeys - keys to remove from the storage
        Since:
        2022.04.2
      • putValuesAndFlush

        void putValuesAndFlush​(@NotNull
                               java.util.Map<java.lang.String,​java.lang.String> data)
        Same as putValues(Map) but if storage is not created yet, then the method ensures that the storage will be created with the provided data so that other processes could see it's data immediately. If the storage already exists, then this is equivalent to:
           putValues(map);
           flush();
         
      • getValues

        @Nullable
        java.util.Map<java.lang.String,​java.lang.String> getValues()
        Retrieves values from the storage
        Returns:
        custom data map or null if there were no data
      • getValue

        @Nullable
        java.lang.String getValue​(@NotNull
                                  java.lang.String key)
        Returns value stored for the specified key
        Parameters:
        key - key
        Returns:
        stored value or null
      • putValue

        void putValue​(@NotNull
                      java.lang.String key,
                      @Nullable
                      java.lang.String value)
        Puts specified value into the storage. If value is null then data with specified key is removed from the storage.
        Parameters:
        key - key
        value - value
      • clear

        void clear()
        Clears data in custom data storage. Same as putValues(Map) called with empty map.
        Since:
        10.0.2
      • dispose

        void dispose()
        Disposes (destroys) this custom data storage.
        Since:
        8.0
      • refresh

        void refresh()
        Refreshes data from the underlying storage
        Since:
        2018.2
      • isDirty

        boolean isDirty()
        Returns:
        true if this custom data storage was modified but the data is not persisted yet
        Since:
        2022.04.1
      • getDataLoadTime

        @Nullable
        java.util.Date getDataLoadTime()
        For a storage whose values have been loaded from the database returns the timestamp when the data was loaded. If the storage has been obtained but getValues() or getValue() methods were not called, then the data may not be loaded into the storage yet. In such cases null is returned as the load time. Storage modifications via put* methods do not affect the load time.
        Returns:
        the timestamp of the last fetching of the storage data from the database
        Since:
        2022.10.1