Interface SCache<T>

  • All Known Implementing Classes:
    SCacheImpl

    public interface SCache<T>
    Basic persistent cache support.
    Since:
    6.0
    Author:
    kir
    See Also:
    CacheProvider
    • Method Detail

      • getName

        String getName()
        Name of the cache, as specified upon cache creation
      • write

        void write​(@NotNull
                   String key,
                   @Nullable
                   T value)
        Put a value to cache with default time to live and time to idle
        Parameters:
        key - cache key
        value - serializable value. If null, cached value is removed
      • write

        @Deprecated
        void write​(@NotNull
                   String key,
                   @Nullable
                   T value,
                   int ttlSecs)
        Deprecated.
        since 8.0 please use ttL set for the whole cache instead
        Put a value to cache with timeout (time to live)
        Parameters:
        key - cache key
        value - serializable value. If null, cached value is removed
        ttlSecs - Time to live for cached value in seconds. 0 means no TTL (eternal)
      • read

        @Nullable
        T read​(@NotNull
               String key)
        Read cache value
      • getKeys

        @NotNull
        Collection<String> getKeys()
        Returns:
        keys for values stored in cache
      • fetch

        T fetch​(String key,
                Calculator<T> dataFetcher)
        Get data from cache, if available. If not, obtain the data using dataFetcher and put them to the cache. The operation is blocking for a particular key. I.e. multiple fetch operations for a single key will wait until first of them will fill the cache.
        Parameters:
        key - cache key
        dataFetcher - a procedure to obtain data if it is not found in the cache (data is put to the cache in this case)
        Returns:
        data from cache or from the dataFetcher
      • invalidate

        void invalidate​(@NotNull
                        String key)
        Delete cache value for particular key
      • invalidateAll

        void invalidateAll()
        Invalidates (removes) all cache elements
        Since:
        9.1.1
      • flush

        void flush()
        Flush all the cache data to the disk
      • setAllowToReset

        void setAllowToReset​(boolean allow)
        Specify whether it is allowed to reset this cache from UI from the Diagnostic->Caches page.
        Since:
        8.0
      • dispose

        void dispose()
        Flushes data on disk (if cache is persistable) and frees all of the resources associated with this cache.