pathable:meteor-fast-methods

v0.2.4Published 5 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

Meteor fast methods

Distributed cached methods and initial data population for free with redis-oplog. Fast-render revamped.

Usage

Preload data

For loading data directly on minimongo for each page serve, use the following on the server:

preloadData(sink => {
  const { community } = getContext(sink, true) || {};
  return [Images.find({ communityId: community._id })];
});

Sink is the meteor server-render package object. this.userId and Meteor.user() are available in this context, instead of pure sink methods.

pro-tip: You can control the data based on routes by getting sink.request.url.pathname

Cached Methods

Define new methods with CachedValidatedMethod exported from this package, and set enableCache: true. They will be automatically cached on redis.

1export default new CachedValidatedMethod({
2  name: 'dataImport/importJobs#update',
3  mixins: [updatable(ImportJobs), scopedMethod],
4  validate: updateSchema.validator(),
5  enableCache: true,
6});

Configuration

//TODO: Cache expiration time