DataCachingListener

DataCachingListener

Represents a data caching listener which is going to be used while executing queries against data models where data caching is enabled. This listener is registered by default.

Data caching may be disabled when DataModel.caching property is set to 'none'. This is the default behaviour of a data model.


 {
     "name": "Order", ... , "caching":"none"
     ...
 }
 

Data caching may be used when DataModel.caching property is set to 'always'.


 {
     "name": "OrderStatus", ... , "caching":"always"
     ...
 }
 

Data caching may be conditionally enabled when DataModel.caching property is set to 'conditional'.


 {
     "name": "Product", ... , "caching":"conditional"
     ...
 }
 

In this case, data caching will be used when an instance of DataQueryable class requests data with cache equal to true:


    context.model('Product')
            .where('category').is('Laptops')
            .cache(true)
            .orderBy('name')
            .list().then(function(result) {
                done(null, result);
            }).catch(function(err) {
                done(err);
            });
 

Constructor

new DataCachingListener()

Source:

Methods

afterExecute(e, callback)

Occurs before executing an query expression, validates data caching configuration and stores data to cache.
Parameters:
Name Type Description
e DataEventArgs | * An object that represents the event arguments passed to this operation.
callback function A callback function that should be called at the end of this operation. The first argument may be an error if any occured.
Source:

beforeExecute(event, callback)

Occurs before executing an query expression, validates data caching configuration and gets cached data.
Parameters:
Name Type Description
event DataEventArgs | * An object that represents the event arguments passed to this operation.
callback function A callback function that should be called at the end of this operation. The first argument may be an error if any occured.
Source: