Package jetbrains.buildServer.util.impl
Class PersistentBinaryDataCache
- java.lang.Object
-
- jetbrains.buildServer.util.impl.PersistentBinaryDataCache
-
- All Implemented Interfaces:
BinaryDataCache
public class PersistentBinaryDataCache extends Object implements BinaryDataCache
- Author:
- Sergey.Anchipolevsky Date: 02.07.2009
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jetbrains.buildServer.util.BinaryDataCache
BinaryDataCache.Entry
-
-
Constructor Summary
Constructors Constructor Description PersistentBinaryDataCache(File dir)
PersistentBinaryDataCache(File dir, int maxElementsInMemory, int maxElementsOnDisk, int timeToLiveSeconds)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
flush()
BinaryDataCache.Entry
get(String key)
Returns the content element associated with the key.Collection<String>
getKeys()
boolean
hasEntry(String key)
Whether some value with the key is present in the cachevoid
invalidate(String key)
Invalidates the data associated with the key.void
put(String key, InputStream stream)
Stores the data presented by the stream object for the given key.void
putBytes(String key, byte[] bytes)
Stores the data presented by the byte array for the given key.void
shutdown()
-
-
-
Method Detail
-
put
public void put(@NotNull String key, @Nullable InputStream stream)
Description copied from interface:BinaryDataCache
Stores the data presented by the stream object for the given key. The caller is responsible for closing the stream.- Specified by:
put
in interfaceBinaryDataCache
- Parameters:
key
- the keystream
- the data stream. Null is acceptable.
-
putBytes
public void putBytes(@NotNull String key, @Nullable byte[] bytes)
Description copied from interface:BinaryDataCache
Stores the data presented by the byte array for the given key. UsingBinaryDataCache.put(String, java.io.InputStream)
is preferable unless you have binary data in memory.- Specified by:
putBytes
in interfaceBinaryDataCache
- Parameters:
key
- the keybytes
- the data. Null is acceptable.
-
hasEntry
public boolean hasEntry(@NotNull String key)
Description copied from interface:BinaryDataCache
Whether some value with the key is present in the cache- Specified by:
hasEntry
in interfaceBinaryDataCache
- Parameters:
key
- the key- Returns:
- true if present (even null) and false otherwise
-
get
@Nullable public BinaryDataCache.Entry get(@NotNull String key)
Description copied from interface:BinaryDataCache
Returns the content element associated with the key.- Specified by:
get
in interfaceBinaryDataCache
- Parameters:
key
- the key- Returns:
- the element or null if no entry is present in the cache.
-
getKeys
@NotNull public Collection<String> getKeys()
-
invalidate
public void invalidate(@NotNull String key)
Description copied from interface:BinaryDataCache
Invalidates the data associated with the key.- Specified by:
invalidate
in interfaceBinaryDataCache
- Parameters:
key
- the key
-
shutdown
public void shutdown()
-
flush
public void flush()
-
-