Newer Version Available
Partition Class
Namespace
Cache Key Format for Partition Methods
After you obtain the partition object (an instance of Cache.OrgPartition or Cache.SessionPartition), the methods to add, retrieve, and manage the cache values in a partition take the key name. The key name that you supply to these methods (get(), put(), remove(), and contains()) doesn’t include the namespace.partition prefix.
Partition Methods
The following are methods for Partition.
contains(key)
Signature
public Boolean contains(String key)
Parameters
- key
- Type: String
- A case-sensitive string value that uniquely identifies a cached value.
createFullyQualifiedKey(namespace, partition, key)
Signature
public static String createFullyQualifiedKey(String namespace, String partition, String key)
Parameters
Return Value
Type: String
createFullyQualifiedPartition(namespace, partition)
Signature
public static String createFullyQualifiedPartition(String namespace, String partition)
Parameters
Return Value
Type: String
get(key)
Signature
public Object get(String key)
Parameters
- key
- Type: String
- A case-sensitive string value that uniquely identifies a cached value.
Return Value
Type: Object
The cached value as a generic object type. Cast the returned value to the appropriate type.
getKeys()
isAvailable()
Signature
public Boolean isAvailable()
Return Value
Type: Boolean
put(key, value)
Signature
public void put(String key, Object value)
Parameters
- key
- Type: String
- A case-sensitive string value that uniquely identifies a cached value.
- value
- Type: Object
- The value to store in the cache. The cached value must be serializable.
Return Value
Type: void
put(key, value, visibility)
Signature
public void put(String key, Object value, cache.Visibility visibility)
Parameters
- key
- Type: String
- A case-sensitive string value that uniquely identifies a cached value.
- value
- Type: Object
- The value to store in the cache. The cached value must be serializable.
- visibility
- Type: Cache.Visibility
- Indicates whether the cached value is available only to Apex code that is executing in the same namespace or to Apex code executing from any namespace.
Return Value
Type: void
put(key, value, ttlSecs)
put(key, value, ttlSecs, visibility, immutable)
Signature
public void put(String key, Object value, Integer ttlSecs, cache.Visibility visibility, Boolean immutable)
Parameters
- key
- Type: String
- A case-sensitive string value that uniquely identifies a cached value.
- value
- Type: Object
- The value to store in the cache. The cached value must be serializable.
- ttlSecs
- Type: Integer
- The amount of time, in seconds, to keep the cached value in the cache.
- visibility
- Type: Cache.Visibility
- Indicates whether the cached value is available only to Apex code that is executing in the same namespace or to Apex code executing from any namespace.
- immutable
- Type: Boolean
- Indicates whether the cached value can be overwritten by another namespace (false) or not (true).
Return Value
Type: void
remove(key)
Signature
public Boolean remove(String key)
Parameters
- key
- Type: String
- A case-sensitive string value that uniquely identifies a cached value.
validateKey(isDefault, key)
validateKeyValue(isDefault, key, value)
Signature
public static void validateKeyValue(Boolean isDefault, String key, Object value)
Parameters
Return Value
Type: void
validateKeys(isDefault, keys)
validatePartitionName(name)
Signature
public static void validatePartitionName(String name)
Parameters
- name
- Type: String
- The name of the partition to validate.
Return Value
Type: void