public class

AttachmentCache

extends Object
java.lang.Object
   ↳ com.atlassian.confluence.pages.attachments.AttachmentCache

Class Overview

Caches the IDs of current attachments by the normal lookup mechanism: content ID + file name. The returned ID can be used for a second-level cache lookup in Hibernate via get(Class, java.io.Serializable).

Doesn't cache misses.

Because the persistent ID of the latest version of an attachment never changes, there's no need to synchronise this cache when an attachment is modified.

Summary

Public Constructors
AttachmentCache(CacheManager cacheManager)
Public Methods
boolean contains(long contentId, String fileName)
Returns true if the cache contains the composite key of content ID + file name.
Long get(long contentId, String fileName)
Returns the ID of the attachment with the given content ID, file name and version, or null if no attachment is in the cache.
void put(Attachment attachment)
Caches the ID of the current version of an attachment (which should never change) against its content ID + file name.
void remove(Attachment attachment)
Removes the given attachment from the cache.
void removeAll()
Removes all entries from the cache.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AttachmentCache (CacheManager cacheManager)

Public Methods

public boolean contains (long contentId, String fileName)

Returns true if the cache contains the composite key of content ID + file name.

public Long get (long contentId, String fileName)

Returns the ID of the attachment with the given content ID, file name and version, or null if no attachment is in the cache.

public void put (Attachment attachment)

Caches the ID of the current version of an attachment (which should never change) against its content ID + file name. If the provided attachment is null or is not the latest version of that attachment, does nothing.

Throws
IllegalArgumentException if the attachment's content reference is null.

public void remove (Attachment attachment)

Removes the given attachment from the cache. Does nothing if the attachment is not in the cache, or the attachment is not the latest version of that attachment.

Throws
IllegalArgumentException if the attachment's content reference is null.

public void removeAll ()

Removes all entries from the cache.