-
Notifications
You must be signed in to change notification settings - Fork 1
Server Cache
Home / Developer / Server Tier / Cache
Configuration Server Cache using Memcached with examples.
PDF-API uses Memcached as a caching system. See https://memcached.org/ for details.
Memcached methods are built into the API class. Please refer to API documentation for full details.
The Memcached configuration is held in Web.config. The cache is usually held on a separate server. Required Application parameters:
- API_MEMCACHED_ENABLED - Switch on [TRUE] or off [FALSE] the MemCacheD .
- API_MEMCACHED_MAX_VALIDITY - Maximum validity in number of seconds that MemCacheD can handle (30 days = 2592000). Note that this cannot be set higher than 2592000.
- API_MEMCACHED_SALSA - Salsa code to isolate the cache records form other applications or environments.
The address and port values must be set in the Memcached config section.
Two custom attributes have been created to ensure that selected APIs will always have specific caching behaviour:
-
CacheRead - This means that the API will always try to read a cache before going to the database. If no cached data is found then the database is read and a cache is created from the result. The property CAS_REPOSITORY must be set to a specific identifying value when asserting this attribute. This attribute is applied only to Read APIs. You may also apply an optional domain value. This is typically a property of the DTO and if it is asserted it will be set to the value of that property.
Example attributes:
[CacheRead(CAS_REPOSITORY = "C_CAS_NAVIGATION_READ")]
[CacheRead(CAS_REPOSITORY = "C_CAS_DATA_CUBE_READ", DOMAIN = "matrix")]
-
CacheFlush - This means that the API will always flush the cache after successful completion. The property CAS_REPOSITORY must be set to a specific identifying value when asserting this attribute. This attribute is applied only to Create, Update and Delete APIs. Because it is possible that more than one cache needs to be flushed, the CAS_REPOSITORY values are stored as a comma separated string. Also, if you need to include a domain value, you do this by appending a '/' character to the CAS_REPOSITORY value and putting the domain value after that. The domain value will typically be a DTO property and including it will add the value of the property to the string. If no domain is required then you do not need to append the "/[domain]" value.
Example attributes:
[CacheFlush(CAS_REPOSITORY_DOMAIN_LIST = "C_CAS_NAVIGATION_READ")]
[CacheFlush(CAS_REPOSITORY_DOMAIN_LIST = "C_CAS_DATA_CUBE_READ/MtrCode,C_CAS_DATA_CUBE_PREREAD/RlsCode")]