It would be fine to also let plugins to manage content directly in Redis, using the cacheEngine.
either activate the cacheEngine by default and let its usage transparent for the plugin developer (as main Repository class does)
or expose to the plugins some methods that use the storageEngine, and some others that use the cacheEngine, like that (in pluginContext.js):
this.constructors.Repository = function PluginContextRepository (collection, ObjectConstructor = null) {
if (!collection) {
throw new PluginImplementationError('The collection must be specified.');
}
const pluginRepository = new PluginRepository(kuzzle, internalEngineIndex, collection);
pluginRepository.init({databaseEngine: pluginInternalEngine, ObjectConstructor});
return {
// Actual methods that use the storage engine :
search: pluginRepository.search.bind(pluginRepository),
get: pluginRepository.loadOneFromDatabase.bind(pluginRepository),
mGet: pluginRepository.loadMultiFromDatabase.bind(pluginRepository),
delete: pluginRepository.deleteFromDatabase.bind(pluginRepository),
create: (object, options = {}) => pluginRepository.pestistToDatabase(object, Object.assign({method: 'create'}, options)),
createOrReplace: (object, options = {}) => pluginRepository.pestistToDatabase(object, Object.assign({method: 'createOrReplace'}, options)),
replace: (object, options = {}) => pluginRepository.pestistToDatabase(object, Object.assign({method: 'replace'}, options)),
update: (object, options = {}) => pluginRepository.pestistToDatabase(object, Object.assign({method: 'update'}, options)),
// New methods that use the cache engine :
cache: {
read: pluginRepository.loadFromCache.bind(pluginRepository),
write: pluginRepository.persistToCache.bind(pluginRepository)
remove: pluginRepository.deleteFromCache.bind(pluginRepository),
}
};
}
For now, the
PluginRepository
exposes methods to manage contents only in the storage engine, not in the cache engine (see https://github.com/kuzzleio/kuzzle/blob/rc.x/lib/api/core/models/repositories/pluginRepository.js and https://github.com/kuzzleio/kuzzle/blob/rc.x/lib/api/core/plugins/pluginContext.js#L112)It would be fine to also let plugins to manage content directly in Redis, using the cacheEngine.
either activate the cacheEngine by default and let its usage transparent for the plugin developer (as main
Repository
class does) or expose to the plugins some methods that use the storageEngine, and some others that use the cacheEngine, like that (inpluginContext.js
):