com.atlassian.confluence.pages.attachments
Class AttachmentCache

java.lang.Object
  extended by com.atlassian.confluence.pages.attachments.AttachmentCache

public class AttachmentCache
extends Object

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 Session.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.

Since:
3.0
See Also:
CachingAttachmentDao

Constructor Summary
AttachmentCache(com.atlassian.cache.CacheManager cacheManager)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttachmentCache

public AttachmentCache(com.atlassian.cache.CacheManager cacheManager)
Method Detail

contains

public boolean contains(long contentId,
                        String fileName)
Returns true if the cache contains the composite key of content ID + file name.


put

public void put(Attachment attachment)
         throws IllegalArgumentException
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.

get

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.


remove

public void remove(Attachment attachment)
            throws IllegalArgumentException
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.

removeAll

public void removeAll()
Removes all entries from the cache.



Copyright © 2003-2013 Atlassian. All Rights Reserved.