Class MessageCacheImpl

    • Constructor Detail

      • MessageCacheImpl

        public MessageCacheImpl​(DiscordApi api,
                                int capacity,
                                int storageTimeInSeconds,
                                boolean automaticCleanupEnabled)
        Creates a new message cache.
        Parameters:
        api - The discord api instance.
        capacity - The capacity of the cache, not including messages which are cached forever.
        storageTimeInSeconds - The storage time in seconds.
        automaticCleanupEnabled - Whether automatic message cache cleanup is enabled.
    • Method Detail

      • addMessage

        public void addMessage​(Message message)
        Adds a message to the cache.
        Parameters:
        message - The message to add.
      • addCacheForeverMessage

        public void addCacheForeverMessage​(Message message)
        Adds a message to be cached forever.
        Parameters:
        message - The message to add.
      • removeCacheForeverMessage

        public void removeCacheForeverMessage​(Message message)
        Removes a message to be cached forever.
        Parameters:
        message - The message to remove.
      • removeMessage

        public void removeMessage​(Message message)
        Removes a message from the cache.
        Parameters:
        message - The message to remove.
      • clean

        public void clean​()
        Cleans the cache.
      • cleanup

        public void cleanup​()
        Description copied from interface: Cleanupable
        Does any cleanup that would prevent this instance from being eligible for garbage collection like cancelling scheduled repeated tasks or calling cleanup on "owned" cleanupable objects. This method has to be thread-safe and idempotent.
        Specified by:
        cleanup in interface Cleanupable