About

Record Cache plug-in can be used to store and retrieve meta-searched records in memory for the duration of the users HTTP session.

The cache could be used to list recently viewed records or maintain a folder of records to be exported.

Protocol

Assuming the plug-in has been mapped to the recordcache chain (see configuration) it is invoked with:

  GET /service-proxy/?command=recordcache

Request parameters

Valid parameters are: action, source, section, id, windowid.

action

Specifies the action to be performed by the plug-in.

Possible values are:

  • create - caches a record from the active session.
  • list - lists records from the cache
  • delete - deletes one or more records from the cache
  • read - reads one record from the cache

Depending on the value of the action parameter, additional parameters may be required.

source

The parameter source specifies where the record to store is to be taken from. This parameter is mandatory for the create action and only applies to that action.

Possible values are:

  • show - extracts a record by it's record id from the latest show request
  • record - extracts a record from the results of the latest record request

section

Optional parameter specifying a particular section of the cache. This parameter is optional and only affects the list action.

The cache currently has two sections, the basket and the record view history. If no section is specified the contents of the basket will be returned.

Possible values are:

  • basket - Lists the deliberately saved records
  • viewed - Lists the view history
  • all - Lists all cached records

id

If action is read then a record id must be provided to get the record from the cache.

If the action is create and the source is show, that is, the record should be picked up from the latest show results, then a record id must be provided on the request.

If action is delete, then a record ID can be provided to remove a particular record from the cache. If no id is provided for the delete action, then all records in the cache are removed.

windowid

The windowid (name of the browser window) must be provided for create actions if the site runs multiple parallel Pazpar2 sessions by means of window names (named windowid in the Service Proxy). This is in order to find the Pazpar2 session that has the record. The window ID does not apply to the list, delete or read actions however, since the basket spans all the user's sessions (browser windows).

Examples

Examples:

  Insert a record into the basket from either a show result or a record result
  GET /service-proxy/?command=recordcache&action=create&source=show&id=[pazpar2 recid]&windowid=mkid_1234
  GET /service-proxy/?command=recordcache&action=create&source=record&windowid=mkid_1234
  
  Delete one record or all records from cache:
  GET /service-proxy/?command=recordcache&action=delete&id=[pazpar2 recid]
  GET /service-proxy/?command=recordcache&action=delete
  
  Lists all records currently in the basket
  GET /service-proxy/?command=recordcache&action=list
  Lists recently viewed records
  GET /service-proxy/?command=recordcache&action=list&section=viewed
  
  Gets one record from the cache
  GET /service-proxy/?command=recordcache&action=read&id=[pazpar2 recid]  

Configuration

Registration

This plug-in is configured in service-proxy.properties or equivalent as follows:

  plugins.recordcache  = com.indexdata.serviceproxy.plugins.recordcache.RecordCachePlugin

Chain mapping

The plug-in is mostly stand-alone but it can be chained with record or show to set cache flags on the records in the results returned by the Service Proxy.

Chaining it with record will also enable caching of recently viewed records.

Examples:

  chains.recordcache = recordcache  # Provides create/list/delete features as described above
  chains.record = relay,recordcache # Adds records to view history and sets the 
                                    # basket status on the record returned by Service Proxy
  chains.show = relay,recordcache   # Sets basket status on hits in <<show>> results

Mandatory properties

  # None

Optional properties

  recordcache.MAX_BASKET_SIZE = 50    # The maximum number of records a user can
                                      # store in memory. The oldest record will 
                                      # be removed when a new record is added
                                      # beyond the maximum size
                                      # Default: 50
  recordcache.MAX_VIEWED_SIZE = 10    # The maximum number of viewed records that
                                      # that are cached for history. As more than 
                                      # the maximum number of records are viewed 
                                      # the oldest are removed from history
                                      # Default: 10