Attributes is used to define how an object should be managed by the cache.
Each Object in the cache has attributes associate with it. See User's
Guide about how each attribute affects the various object types.
Since:
2.0.0
Field Summary
static long
ALLOWNULL
indicates null values may be cached for this object or region.
static long
DISTRIBUTE
indicates the object is distributed, updates and invalidations are
distributed to other processes Default is local.
static long
GROUP_TTL_DESTROY
indicates that the group object should be destroyed when the
associated time to live expires.
static long
MEASURE
indicates the object size should be calculated by the cache.
static long
ORIGINAL
indicates the object was created by the application in the cache rather
than loaded from an external source. the Original objects don't get
removed from the cache when they are not referenced, they must be
invalidated before they get removed from the cache.
static long
REPLY
indicates a reply should be sent from remote caches if this object
is updated or invalidated.
static long
SPOOL
indicates the object should be spooled to disk when the object is
being removed from the memory cache because of space limitations.
static long
SYNCHRONIZE
indicates that updates to this object should be synchronized.
static long
SYNCHRONIZE_DEFAULT
indicates that all objects in a group should be synchronized
individually.
setClassLoader(java.lang.ClassLoader aLoader)
set a ClassLoader.
void
setDefaultTimeToLive(long sec)
sets the default maximum time all objects associated with this group
or region will stay in the cache before it is invalidated.
void
setFlags(long newFlags)
specifies which of the listed attributes should be set in the Attributes
object.
void
setFlagsToDefault()
resets this Attributes object to contain default
Attributes values.
void
setIdleTime(int idle)
sets the maximum time the associated cache object will remain in the
cache without being referenced before it is invalidated.
setMaxCount(int count)
sets the maximum number of objects that can be associated with a region
This attribute is ignored if set for individual objects
void
setMaxSize(long size)
sets the maximum number of bytes that can be associated with a region
This attribute is ignored if set for individual objects
void
setPriority(int priority)
sets the priority associated with this cache object
Priority is used to help determine which objects should be removed
from the cache when the configured capacity of the cache or region
is reached.
void
setSize(long objSize)
sets the size of the object.
void
setTimeToLive(long sec)
sets the maximum time the associated cache object will stay in the
cache before it is invalidated.
void
setUserAttribute(java.lang.Object key,
java.lang.Object value)
allows the user to define applications specific attributes.
void
setVersion(long newversion)
sets the version attribute.
static long
timeToSeconds(int days,
int hours,
int minutes,
int seconds)
converts the time specified in days, hours, minutes and seconds to seconds.
java.lang.String
toString()
converts the Attributes object to a string of the form:
flags, version, time to live, idle time.
indicates a reply should be sent from remote caches if this object
is updated or invalidated. The default is not to reply. This flag
is ignored if the object is local.
indicates that updates to this object should be synchronized. If this
flag is set only the "owner" of an object can load or replace the object.
The "owner" of an object is a CacheAccess object. Synchronize doesn't
prevent a user from reading or invalidating the object.
indicates the object should be spooled to disk when the object is
being removed from the memory cache because of space limitations.
This flag is only valid for memory objects.
indicates that the group object should be destroyed when the
associated time to live expires. In the default case only the child
objects are invalidated the group remains valid.
indicates the object was created by the application in the cache rather
than loaded from an external source. the Original objects don't get
removed from the cache when they are not referenced, they must be
invalidated before they get removed from the cache.
indicates that all objects in a group should be synchronized
individually. Each user object in the group (or subgroup) will
by marked as synchronized. Ownership of the object must be obtained
before the object can be loaded or updated. Synchronize doesn't
prevent a user from reading or invalidating the object.
indicates null values may be cached for this object or region.
By default a null is an invalid object in the cache. Attempting to
cache a null value will generate an exception. This flag will override
this restriction allowing nulls to be cached.
indicates the object size should be calculated by the cache.
If the MEASURE flag is set, the size of an object is automatically
calculated when the object is loaded into the cache. The size attributed
is set to this size. This allows the cache and region size to be
controlled by the object size (number of bytes) rather than the number
of objects.
constructs a default Attributes. By default all the flag values are off,
the version number is 0, no idleTime, TimeToLive or listener is set.
Since:
2.0.0
Method Detail
setFlags
public void setFlags(long newFlags)
specifies which of the listed attributes should be set in the Attributes
object. The flags may be OR'ed together, * i.e.,
Attributes.DISTRIBUTE|Attributes.SPOOL. Any previous settings
will be disregard.
Parameters:
newFlags - can be a combination of the following values:
DISTRIBUTE indicates the object should be distributed,
updates and invalidations will be distributed if the cache is set
to be distributed. The default for both the cache and the object is
local.
REPLY indicates a reply should be sent from remote caches
if this object is updated or invalidated. The default is not to reply.
This flag is ignored if the object is local.
SYNCHRONIZE indicates that updates to this object, region
or group should be synchronized. If this flag is set only the "owner"
of an object can load or replace the object. The "owner" of an object
is a CachAccess object instance. The default is not to synchronize.
Synchronizing an object doesn't prevent a user from reading or
invalidating an object.
SYNCHRONIZE_DEFAULT indicates all objects in a region or
group should be synchronized individually. If both SYNCHRONIZE and
SYNCHRONIZE_DEFAULT are set, SYNCHRONIZE will take presidence. The
SYNCHRONIZE_DEFAULT flag will be ignored.
SPOOL indicates the object should be spooled to disk when the
object is being removed from the memory cache because of space
limitations. This flag is only valid for memory objects.
GROUP_TTL_DESTROY indicates that the group object should be
destroyed when the associated time to live expires. In the default case
only the child objects are invalidated the group remains valid.
ORIGINAL indicates the object was created in the cache and
can't be recreated it was removed from the. Original objects don't
get removed from the cache when they are not referenced they must be
invalidated before they get removed from the cache.
ALLOWNULL indicates null values may be cached for this object or region
By default a null is an invalid object in the cache. Attempting to
cache a null value will generate an exception. This flag will override
this restriction allowing nulls to be cached.
MEASURE indicates the object size should be calculated by the cache
If the MEASURE flag is set, the size of an object is automatically
calculated when the object is loaded into the cache. The size
attributed is set to this size. This allows the cache and region
size to be controlled by the object size (number of bytes) rather
than the number of objects.
Since:
2.0.0
getFlags
public long getFlags()
returns all flags as defined in setFlags as a long value.
Returns:
the current value of the flags in a long value.
Since:
2.0.0
setFlagsToDefault
public void setFlagsToDefault()
resets this Attributes object to contain default
Attributes values.
Since:
2.0.0
setVersion
public void setVersion(long newversion)
sets the version attribute. A version number is maintained
for the users convenience. It is not used internally by the cache.
sets the maximum time the associated cache object will stay in the
cache before it is invalidated. The timeToSeconds()
method may be used to convert days, hours, and/or minutes
to seconds.
Parameters:
sec - Maximum time (in seconds) the associated cache object will stay
in the cache before it is invalidated.
sets the default maximum time all objects associated with this group
or region will stay in the cache before it is invalidated. Default
TimeToLive differs from TimeToLive in that it is applied to each
object in the group or region individually rather than to the group
as a whole. For individual objects, defaultTimeToLive and timeToLive
are equivalent. If both are set, timeToLive takes precedence. The
timeToSeconds() method may be used to convert days,
hours, and/or minutes to seconds.
Parameters:
sec - Maximum time (in seconds) the associated cache object will stay
in the cache before it is invalidated.
sets the maximum time the associated cache object will remain in the
cache without being referenced before it is invalidated. idle
is in seconds. The timeToSeconds() method may be used to
convert days, hours, and/or minutes to seconds.
Parameters:
idle - Maximum time (in seconds) the associated cache object will
remain in the cache without being referenced before
it is invalidated.
sets the priority associated with this cache object
Priority is used to help determine which objects should be removed
from the cache when the configured capacity of the cache or region
is reached. The higher the integer value the less likely the object will
be removed from the cache to clear space for another object.
Parameters:
priority - priority associated with this cache object
registers an event listener object to be executed when the event occurs.
Only OBJECT_INVALIDATED and OBJECT_UPDATED
are currently supported. If the
def parameter is true then for groups and regions
the event listener is associated with members of the group or region
rather than the group or region itself. For individual objects the
def parameter is ignored.
Parameters:
id - the id of the event to be handled
listener - A CacheEventListener object.
def - true if the handler should apply to the members of a group or
region individually rather than the group or region itself
Throws:
InvalidArgumentException - if the event type
(argument id)
is not CacheEvent.OBJECT_INVALIDATED or
CacheEvent.OBJECT_UPDATED .
Since:
2.0.0
setClassLoader
public void setClassLoader(java.lang.ClassLoader aLoader)
set a ClassLoader. This attributes only applies to regions.
This ClassLoader will be used to load objects in the region.
A ClassLoader attribute will be ignored if this attribute is associated
with an Object.
getClassLoader
public java.lang.ClassLoader getClassLoader()
get the ClassLoader attribute.
Returns:
ClassLoader if there is a ClassLoader defined; null, otherwise.
sets a CapacityPolicy object for the object or region
Parameters:
policy - The CapacityPolicy object to be set in this Attribute.
Since:
9.0.4
setSize
public void setSize(long objSize)
sets the size of the object. This tells the Cache system how big the
cached object would be. The number would be added to the total Cache
size of the system.
Parameters:
objSize - is the size of the object in bytes.
Since:
2.0.0
setUserAttribute
public void setUserAttribute(java.lang.Object key,
java.lang.Object value)
throws InvalidArgumentException
allows the user to define applications specific attributes.
These user defined attributes are available to the user defined methods
CacheLoader, CapacityPolicy and
CacheEventListeners through the getAttributes method
associated with these objects.
returns a CapacityPolicy object for this object or region
Returns:
A CapacityPolicy object which was set in this Attribute object.
Since:
9.0.4
isSet
public boolean isSet(long vflags)
returns true if the specified attribute is set, false otherwise.
Flags may be OR'ed together in which case isSet() will return
true only if all of the attributes specifed are set.
Parameters:
vflags - Verify if a particular attribute is set.
Returns:
True if the specified attribute is set.
Since:
2.0.0
getVersion
public long getVersion()
returns the current value of version.
Returns:
The current value of an user-defined version number.
Since:
2.0.0
getCreateTime
public long getCreateTime()
returns the time the object was loaded into the cache. The time is the
number of milliseconds from midnight, January 1, 1970 (UTC).
Returns:
The time the object was loaded into the cache.
Since:
2.0.0
getTimeToLive
public long getTimeToLive()
returns the current value for the time to live interval.
Returns:
The current value for the time to live interval.
Since:
2.0.0
getIdleTime
public long getIdleTime()
returns the current value for the idle time interval.
Returns:
The current value for the idle time interval.
Since:
2.0.0
getPriority
public long getPriority()
returns the current value for priority
Returns:
The current value for priority
Since:
9.0.4
getMaxCount
public long getMaxCount()
returns the current value for maxCount
MaxCount is the maximum number of objects that can exist in a group or
region. Once this limit is reached an object must be removed before a
new object can be places in the cache. To determine which object is
removed, the capacityPolicy for the group or region will be invoked.
Returns:
The current value for maxCount
Since:
9.0.4
getMaxSize
public long getMaxSize()
returns the current value for maxSize
MaxSize is the maximum number of bytes this region or group can use. If
the MEASURE flag is set the size of objects in the cache
will be calculated at the time the object is loaded into the cache.
If this flag is not set, it is up to the user to set the object size
using the setSize(long) method. The maxSize attribute is
only valid for regions and groups. It will be ignored if set on
individual objects.
Returns:
The current value for maxSize
Since:
9.0.4
getObjectSize
public long getObjectSize()
returns the size of the object which was specified by
invoking setSize(long).
Returns:
The current value for object size.
Since:
2.0.0
getUserAttribute
public java.lang.Object getUserAttribute(java.lang.Object key)
returns the specified user defined attribute
Parameters:
key - The user attribute to look up
Returns:
The current value for the user attribute "key".
Since:
9.0.4
clone
public java.lang.Object clone()
clones a new Attributes object.
Returns:
an cloned Attributes object
Since:
2.0.0
timeToSeconds
public static long timeToSeconds(int days,
int hours,
int minutes,
int seconds)
throws InvalidArgumentException
converts the time specified in days, hours, minutes and seconds to seconds.