Class UploadStagingCache

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class UploadStagingCache
    extends Object
    implements Closeable
    Cache for staging async uploads. This serves as a temporary cache for serving local requests till the time the upload has not been synced with the backend.

    The appropriate backend for this cache are wrapped in StagingUploader implementations.

    • Method Detail

      • put

        public Optional<SettableFuture<Integer>> put​(String id,
                                                     File input)
        Puts the file into the staging cache if possible. Returns an optional SettableFuture if staged for upload otherwise empty.
        Parameters:
        id - the id of the file to be staged
        input - the file to be staged
        Returns:
        An Optional SettableFuture containing 1 if upload was successful, 0 if an existing id is already pending for upload
      • getIfPresent

        @Nullable
        public @Nullable File getIfPresent​(String key)
        Returns the File if present or null otherwise. Any usage of the returned file should assert for its existence as the file could be purged from the file system once uploaded using the internal scheduled remove mechanism.
        Parameters:
        key - of the file to check
        Returns:
        a File object if found