Class CacheThing
java.lang.Object
com.thingworx.types.NamedObject
com.thingworx.persistence.common.PersistableNamedObject
com.thingworx.entities.RootEntity
com.thingworx.things.Thing
com.thingworx.things.cache.custom.CacheThing
- All Implemented Interfaces:
ISupportsAccessModifier,IConfigurableObject,INotScriptFriendly,ISupportsDeprecation,IDiffableObject,IAlertProvider,IAvatar,IEntityLifeCycleEvent,IEventMetadataProvider,IEventProvider,IPersistable,IPropertyProvider,IServiceMetadataProvider,IServiceProvider,IShapeProvider,ITaggableObject,IDependencyScannableObject,IImportDependencyHandler,IData,IDynamicServiceShape,IHierarchicalEntity,IEntityDefinition,IPersistableObject<String>,IDesignTimeSecurable,IDesignTimeSecurableEntity,IRunTimeSecurable,IRunTimeSecurableEntity,ISecurable,IVisibilitySecurable,IVisibilitySecurableEntity,IEventProcessor,IAspectContainer,INamedObject,Serializable
@ThingworxExtensionApiClass(since={10,0},
canInstantiate=true,
canExtendOrImplement=true)
public class CacheThing
extends Thing
implements IData, IDynamicServiceShape
CacheThing allows customers to access a fairly raw backing of a JSR 107 Cache.
There is no guarantee of durability of the cache after system restart.
This Thing requires a configured DataShape with one or more primary Keys. The API is a fairly simple Put-Get-Delete-Clear API based on one-row InfoTables (ValueCollections). There are also Convenience Put-By-Key and Get-By-Key methods.
If ANY of the Cache Configurations are changed, the cache may automatically be purged for those changes to take effect.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class com.thingworx.things.Thing
_logger, BUILT_IN_PROPERTY_DEFINITIONS, DATASHAPE_INCOMING_LOCAL_PROPERTY_BINDING, DEFAULT_SETTINGS_TABLE, ENTITYLIST_SHAPE, GENERIC_THING_TEMPLATE, NON_PROPERTY_BASED_EVENTS, PROPERTY_EVENTS, TYPE_THINGFields inherited from class com.thingworx.entities.RootEntity
BASIC_PROPERTY_DEFINITIONS, EXCLUDED_ENTITY_TYPES_IN_PROJECTFields inherited from class com.thingworx.types.NamedObject
NAME_COMPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeleteEntry(InfoTable values) Service Category: Cache Service Description: Delete an existing data table entry.voidDeleteEntryByKey(String key) Service Category: Cache Service Description: Deletes a Cache entry using the configured DataShape's PrimaryKey String value.EstimateEntrySize(InfoTable values) Service Category: Cache Service Description: Estimate the size of a single entry.Service Category: DataShape Service Description: Get the currently assigned data shape.Returns a map containing references to all entities that the Thing is dependent on.Service Category: Cache Service Description: Get an existing Cache entry, empty if it doesn't exist.GetEntryByKey(String key) Service Category: Cache Service Description: Get an existing Cache entry using the configured DataShape's PrimaryKey String value.Service Category: Cache Service Description: Get a count of Cache entries.voidinitializeThing(ContextType contextType) An initialization hook for subclasses ofThing.Service Category: Cache Service Description: Load value from backing resource (Used for cache loading only - result is not cached by this service).voidService Category: Cache Service Description: Remove all Cache entries.voidService Category: Cache Service Description: Add a new Cache entry, or if it exists, update an existing entry.voidSetDataShape(String name) Service Category: DataShape Service Description: Sets the assigned DataShape.voidvalidateConfiguration(ImportedEntityCollection importedEntityCollections) Validates that the configured dataShape exits, has a primary key, and has runtime access.Methods inherited from class com.thingworx.things.Thing
AcknowledgeAlert, acknowledgeAlertByProperty, acknowledgeAlertByPropertyAndName, acknowledgeAllAlerts, AcknowledgeAllAlerts, AddBooleanValueStreamEntry, AddBooleanValueStreamEntry, AddDateTimeValueStreamEntry, AddDateTimeValueStreamEntry, AddDynamicSubscription, AddEventDefinition, AddImageValueStreamEntry, AddImageValueStreamEntry, AddInfoTableValueStreamEntry, AddInfoTableValueStreamEntry, AddIntegerValueStreamEntry, AddIntegerValueStreamEntry, AddLocationValueStreamEntry, AddLocationValueStreamEntry, AddLongValueStreamEntry, AddLongValueStreamEntry, AddNumberValueStreamEntry, AddNumberValueStreamEntry, AddOrUpdateAlert, addProperty, AddPropertyDefinition, AddPropertyDefinition, AddPropertyDefinition, AddPropertyDefinition, AddPropertyDefinition, AddPropertyDefinitions, AddPropertyTransformDefinition, AddServiceDefinition, AddServiceDefinition, AddStringValueStreamEntry, AddStringValueStreamEntry, AddTags, AddThingCodeValueStreamEntry, AddThingCodeValueStreamEntry, AddVec2ValueStreamEntry, AddVec2ValueStreamEntry, AddVec3ValueStreamEntry, AddVec3ValueStreamEntry, AddVec4ValueStreamEntry, AddVec4ValueStreamEntry, checkDemandRead, checkPropertyName, checkValueStream, cleanupThing, DisableAlertsForProperty, DisableAllAlerts, DisableSubscription, DisableSubscription, DisableThing, dispatchBackgroundEvent, dispatchEvent, dispose, EnableAlertsForProperty, EnableAllAlerts, EnableSubscription, EnableSubscription, EnableThing, fireEvent, getAlertConfigurations, GetAlertDefinition, GetAlertDefinitions, getAlerts, getAlertsForProperty, GetAlertStatus, GetAlertStatuses, GetAlertStatusesForProperty, GetAlertSummary, GetAlertSummaryForProperty, GetAllAnomalyAlertTrainingStatistics, getAllImplementedThingShapes, getAllImplementedThingTemplates, GetAnomalyAlertTrainingStatisticsForAlert, GetAnomalyAlertTrainingStatisticsForProperty, GetAvatar, GetBooleanAlertParameter, GetBooleanPropertyValue, GetDateTimeAlertParameter, GetDateTimePropertyValue, getEffectiveAlertConfiguration, getEffectiveAlertDefinition, getEffectiveEventDefinition, getEffectiveIdentifier, GetEffectiveLocalPropertyBinding, getEffectiveLocalPropertyBindings, GetEffectiveLocalPropertyBindings, getEffectivePropertyDefinition, GetEffectivePropertyLogging, getEffectiveRemoteEventBindings, getEffectiveRemotePropertyBindings, getEffectiveRemoteServiceBindings, getEffectiveServiceDefinition, getEffectiveValueStreamName, getEntityType, GetHomeMashup, getIdentifier, GetIdentifier, GetImagePropertyValue, GetImplementedShapes, getImplementedThingTemplates, GetIncomingLocalPropertyBinding, GetIncomingLocalPropertyBindings, getInstanceEventDefinition, getInstanceEventDefinitions, getInstanceMultiEventSubscriptions, getInstancePropertyDefinition, getInstancePropertyDefinitionIfVisible, getInstancePropertyDefinitions, getInstancePublicServiceDefinitions, getInstanceServiceDefinition, getInstanceServiceDefinitions, getInstanceShape, getInstanceSubscriptions, GetIntegerAlertParameter, GetIntegerPropertyValue, GetLocalAlertDefinitions, GetLocallyImplementedShapes, GetLocalPropertyBinding, GetLocationAlertParameter, GetLocationPropertyValue, GetLoggedProperties, GetLongAlertParameter, GetLongPropertyValue, GetMashups, GetNamedProperties, GetNamedPropertyValues, GetNamedPropertyValuesVTQ, GetNamedPropertyValuesVTQA, GetNetworks, GetNumberAlertParameter, GetNumberPropertyValue, GetNumericLoggedProperties, getProperties, getProperty, getPropertyAckStatus, getPropertyAlertStatus, GetPropertyLogging, getPropertyQuality, GetPropertyQuality, getPropertyTime, GetPropertyTime, getPropertyType, getPropertyValue, getPropertyValue, getPropertyValues, GetPropertyValues, getPropertyValuesAsInfoTable, GetPropertyValuesAsMultiRowTable, GetPropertyValuesVTQ, GetPropertyValuesVTQA, GetPublished, GetRemoteEventBinding, GetRemotePropertyBinding, GetRemoteServiceBinding, getState, GetStringAlertParameter, GetStringPropertyValue, GetThingCodePropertyValue, GetThingGroupDelegatedVisibilityPermissions, GetThingRelationships, GetThingSummaryInformation, getThingTemplate, GetThingTemplate, getThingTemplateName, GetValueStream, getValueStreamName, GetVec2PropertyValue, GetVec3PropertyValue, GetVec4PropertyValue, HasAlert, hasEventDefinition, hasLocalEventDefinition, hasLocalPropertyDefinition, hasLocalServiceDefinition, hasProperty, hasPropertyAndIsVisible, hasPropertyDefinition, hasServiceDefinition, HavePropertiesChangedSince, implementsShape, ImplementsShape, implementsTemplate, initializeEntity, initializeProperty, isAlwaysAvailableService, isBuiltInEvent, isBuiltInProperty, IsDerivedFromTemplate, IsDynamicSubscriptionCreated, isEnabled, IsEnabled, isEventRemote, isExternallySubscribed, IsInNetwork, isLocallySubscribed, isLocalProperty, isPropertyEvent, isPropertyRemote, isPublished, isRunning, isServiceRemote, isSubscribed, preprocessSetPropertyVTQ, processAPIServiceRequest, processServiceRequest, processStartNotification, PurgeAllPropertyHistory, PurgePropertyHistory, PurgeSelectedPropertyHistory, QueryAlertHistory, QueryAlertSummary, QueryBooleanPropertyHistory, QueryBooleanPropertyHistory, QueryDateTimePropertyHistory, QueryDateTimePropertyHistory, QueryImagePropertyHistory, QueryImagePropertyHistory, QueryInfoTablePropertyHistory, QueryInfoTablePropertyHistory, QueryIntegerPropertyHistory, QueryIntegerPropertyHistory, QueryLocationPropertyHistory, QueryLocationPropertyHistory, QueryLongPropertyHistory, QueryLongPropertyHistory, QueryNamedPropertyHistory, QueryNamedPropertyHistory, QueryNamedPropertyHistory, QueryNumberPropertyHistory, QueryNumberPropertyHistory, QueryPropertyHistory, QueryPropertyHistory, QueryPropertyHistory, QueryStringPropertyHistory, QueryStringPropertyHistory, QueryThingCodePropertyHistory, QueryThingCodePropertyHistory, QueryVec2PropertyHistory, QueryVec2PropertyHistory, QueryVec3PropertyHistory, QueryVec3PropertyHistory, QueryVec4PropertyHistory, QueryVec4PropertyHistory, QueuePostCommitEvent, RemoveAlert, RemoveDynamicSubscription, RemoveEventDefinition, RemoveLocalPropertyBinding, RemovePropertyDefinition, RemoveRemoteEventBinding, RemoveRemotePropertyBinding, RemoveRemoteServiceBinding, RemoveServiceDefinition, RestartThing, SetBooleanAlertParameter, SetDateTimeAlertParameter, SetDescription, SetIdentifier, SetIntegerAlertParameter, SetLocalPropertyBinding, SetLocalPropertyBinding, SetLocationAlertParameter, SetNumberAlertParameter, SetPropertyLogging, setPropertyValue, SetPropertyValues, setPropertyVTQ, setPropertyVTQ, SetPublished, SetRemoteEventBinding, SetRemotePropertyBinding, SetRemotePropertyBinding, SetRemoteServiceBinding, SetStringAlertParameter, SetTags, setThingTemplateName, SetUnitsForNumericPropertyDefinition, SetValueStream, startThing, stopThing, UpdatePropertyValues, UpdatePropertyValuesBatched, WritePropertiesToStreamMethods inherited from class com.thingworx.entities.RootEntity
AddConfigurationTableDefinition, AddConfigurationTableDefinition, addDesignTimePermission, AddDesignTimePermission, addRunTimePermission, AddRunTimePermission, addVisibilityPermission, AddVisibilityPermission, CheckDesignTimePermission, CheckDesignTimePermissionForGroup, CheckDesignTimePermissionForUser, CheckPermission, CheckPermissionForGroup, CheckPermissionForUser, cleanupEntity, DeleteAllConfigurationTableRows, DeleteConfigurationTable, DeleteConfigurationTableRows, DeleteConfigurationTableRows, deleteDesignTimePermission, DeleteDesignTimePermission, deleteRunTimePermission, DeleteRunTimePermission, deleteVisibilityPermission, DeleteVisibilityPermission, getAspects, getAvatarContent, GetAvatarURL, GetConfigurationChangeHistory, getConfigurationSetting, getConfigurationTable, GetConfigurationTable, GetConfigurationTableDefinition, GetConfigurationTableRow, GetConfigurationTables, GetDescription, getDesignTimePermissions, GetDesignTimePermissions, GetDesignTimePermissionsAsJSON, getDocumentationContent, getEntityTypeAsString, GetEventDefinition, GetEventDefinitions, GetIncomingDependencies, GetIncomingDependenciesAsNetwork, GetInstanceMetadataAsJSON, GetInstanceMetadataWithPermissionsAsJSON, GetLastModifiedDate, GetMetadata, GetMetadataAsJSON, GetMetadataWithPermissionsAsJSON, GetOutgoingDependencies, GetOutgoingDependenciesAsNetwork, getOwner, GetOwner, GetPermissionsForCurrentUser, GetPermissionsForGroup, GetPermissionsForUser, GetProjectName, GetPropertyDefinition, GetPropertyDefinitions, getRunTimePermissions, GetRunTimePermissions, GetRunTimePermissionsAsJSON, GetServiceDefinition, GetServiceDefinitions, getStringConfigurationSetting, getStringConfigurationSettingWithDefault, GetSummaryInformation, getTags, GetTags, GetTagsAsInfoTable, getVisibilityPermissions, GetVisibilityPermissions, GetVisibilityPermissionsAsJSON, HasIncomingDependencies, HasOutgoingDependencies, isEditable, isEditableExtensionObject, isEditableSystemObject, isExtensionObject, IsMultiRowTable, isOwner, isSystemObject, isThemeObject, isVisible, isVisible, ListDeprecatedUsage, persistDesignTimePermissions, persistRunTimePermissions, persistVisibilityPermissions, preInitializeEntity, RemoveTags, SaveConfigurationTables, SetAvatar, setConfigurationSetting, SetConfigurationTable, SetConfigurationTableRows, setDesignTimePermissions, SetDesignTimePermissionsAsJSON, setDocumentationContent, setExtensionObject, SetHomeMashup, setLastModifiedDate, SetMultiRowConfigurationTable, setOwner, SetOwner, SetProjectName, setRunTimePermissions, SetRunTimePermissionsAsJSON, setStringConfigurationSetting, setVisibilityPermissions, SetVisibilityPermissionsAsJSON, toJSON, toJSONDefinition, UpdateProjectDependenciesMethods inherited from class com.thingworx.persistence.common.PersistableNamedObject
getID, hasID, isTransientMethods inherited from class com.thingworx.types.NamedObject
getDescription, getName, setDescription, setName, toValueCollectionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.thingworx.types.INamedObject
getDescriptionMethods inherited from interface com.thingworx.entities.interfaces.IPersistable
getID, hasIDMethods inherited from interface com.thingworx.security.permissions.ISecurable
getID, getNameMethods inherited from interface com.thingworx.entities.interfaces.IShapeProvider
getNameMethods inherited from interface com.thingworx.accesscontrol.ISupportsAccessModifier
getAccessModifier, getAccessModifierScope, getExemptList, hasAccessModifier, isInternalAccess, isPrivateAccess, isRestrictedAccessMethods inherited from interface com.thingworx.deprecation.ISupportsDeprecation
getDeprecated, isDeprecated, isDeprecatedBefore, since
-
Field Details
-
EXPIRATION_TIME
- See Also:
-
EXPIRATION_POLICY
- See Also:
-
MAXIMUM_SIZE
- See Also:
-
IS_LOADING
- See Also:
-
-
Constructor Details
-
CacheThing
public CacheThing()Initializes this instace with default values.
-
-
Method Details
-
validateConfiguration
@ThingworxExtensionApiMethod(since={10,0}, canOverride=true, requiresSuper=true) public void validateConfiguration(ImportedEntityCollection importedEntityCollections) throws Exception Validates that the configured dataShape exits, has a primary key, and has runtime access. If the dataShape is in importedEntityCollections, check if the datashape fields have been updated at all. If the dataShape fields have changed, then clear the Cache if it exists.NOTE: This is also called if only the DataShape used changes, so we can appropriately check and clear cache if the DS is changing under our feet.
- Overrides:
validateConfigurationin classThing- Parameters:
importedEntityCollections- - a typed collection of entities currently being imported- Throws:
Exception- if the thing is invalid
-
initializeThing
@ThingworxExtensionApiMethod(since={10,0}, canOverride=true, requiresSuper=true) public void initializeThing(ContextType contextType) throws Exception Description copied from class:ThingAn initialization hook for subclasses of
Thing. Some resources ofThingmay not be available at this point in the lifecycle.- Overrides:
initializeThingin classThing- Throws:
Exception- if an error occurs during thing initialization
-
getDataShape
- Specified by:
getDataShapein interfaceIData- Specified by:
getDataShapein interfaceIDynamicServiceShape
-
getDataShapeName
- Specified by:
getDataShapeNamein interfaceIData
-
SetDataShape
- Service Category:
- DataShape
- Service Description:
- Sets the assigned DataShape. The DataShape must have a Primary Key. Changing the DataShape will clear the Cache!.
- Parameters:
name- Data shape name - DATASHAPENAME- Throws:
Exception- if an error occurs
-
GetDataShape
- Service Category:
- DataShape
- Service Description:
- Get the currently assigned data shape.
- Returns:
- result Data shape name - DATASHAPENAME
-
PutEntry
- Service Category:
- Cache
- Service Description:
- Add a new Cache entry, or if it exists, update an existing entry.
- Parameters:
values- Data values - INFOTABLE- Throws:
Exception- if an error occurs
-
LoadEntry
@ThingworxExtensionApiMethod(since={10,0}) public InfoTable LoadEntry(InfoTable values) throws Exception - Service Category:
- Cache
- Service Description:
- Load value from backing resource (Used for cache loading only - result is not cached by this service).
- Parameters:
values- Key values - INFOTABLE- Returns:
- result Table entries - INFOTABLE - Aspects {isEntityDataShape:true}
- Throws:
Exception- if an error occurs
-
GetEntryByKey
@ThingworxExtensionApiMethod(since={10,0}) public InfoTable GetEntryByKey(String key) throws Exception - Service Category:
- Cache
- Service Description:
- Get an existing Cache entry using the configured DataShape's PrimaryKey String value. This Service is only allowed when the configured DataShape has a single PrimaryKey.
- Parameters:
key- Key Value - STRING- Returns:
- result Table entries - INFOTABLE - Aspects {isEntityDataShape:true}
- Throws:
Exception- if an error occurs
-
GetEntry
@ThingworxExtensionApiMethod(since={10,0}) public InfoTable GetEntry(InfoTable values) throws Exception - Service Category:
- Cache
- Service Description:
- Get an existing Cache entry, empty if it doesn't exist.
- Parameters:
values- Key values - INFOTABLE- Returns:
- result Table entries - INFOTABLE - Aspects {isEntityDataShape:true}
- Throws:
Exception- if an error occurs
-
DeleteEntry
@ThingworxExtensionApiMethod(since={10,0}) public void DeleteEntry(InfoTable values) throws Exception - Service Category:
- Cache
- Service Description:
- Delete an existing data table entry.
- Parameters:
values- Data values - INFOTABLE- Throws:
Exception- if an error occurs
-
DeleteEntryByKey
@ThingworxExtensionApiMethod(since={10,0}) public void DeleteEntryByKey(String key) throws Exception - Service Category:
- Cache
- Service Description:
- Deletes a Cache entry using the configured DataShape's PrimaryKey String value. This Service is only allowed when the configured DataShape has a single PrimaryKey.
- Parameters:
key- Key Value - STRING- Throws:
Exception- if an error occurs
-
PurgeCache
- Service Category:
- Cache
- Service Description:
- Remove all Cache entries.
- Throws:
Exception- if an error occurs
-
GetEstimatedEntryCount
- Service Category:
- Cache
- Service Description:
- Get a count of Cache entries.
- Returns:
- result Cache entry count - LONG
- Throws:
Exception- if an error occurs
-
EstimateEntrySize
@ThingworxExtensionApiMethod(since={10,0}) public Long EstimateEntrySize(InfoTable values) throws Exception - Service Category:
- Cache
- Service Description:
- Estimate the size of a single entry.
- Parameters:
values- Data values - INFOTABLE- Returns:
- result Entry size in bytes - LONG
- Throws:
Exception- if an error occurs
-
getDependencies
Description copied from class:ThingReturns a map containing references to all entities that the Thing is dependent on.
- Overrides:
getDependenciesin classThing- Returns:
- a map of up-stream dependencies
-