* feat: improve cache * fix: bug * fix: test * fix: test * fix: test * chore: add cache test * feat: add wrapWithCondition * fix: test * refactor: improve api * fix: test * fix: test * fix: test * fix: improve code * fix: test * feat: register redis store * fix: tst * fix: test * fix: bug * chore: update * fix: ttl unit * chore: cachemanager constructor * chore: remove code * feat: support close connection * chore: add close options for redis store
48 lines
970 B
TypeScript
48 lines
970 B
TypeScript
import { Cache } from '@nocobase/cache';
|
|
import { InstallOptions, Plugin } from '@nocobase/server';
|
|
import { query } from './actions/query';
|
|
import { resolve } from 'path';
|
|
|
|
export class DataVisualizationPlugin extends Plugin {
|
|
cache: Cache;
|
|
|
|
afterAdd() {}
|
|
|
|
beforeLoad() {
|
|
this.app.resource({
|
|
name: 'charts',
|
|
actions: {
|
|
query,
|
|
},
|
|
});
|
|
this.app.acl.allow('charts', 'query', 'loggedIn');
|
|
}
|
|
|
|
async load() {
|
|
this.db.addMigrations({
|
|
namespace: 'data-visulization',
|
|
directory: resolve(__dirname, 'migrations'),
|
|
context: {
|
|
plugin: this,
|
|
},
|
|
});
|
|
|
|
this.cache = await this.app.cacheManager.createCache({
|
|
name: 'data-visualization',
|
|
store: 'memory',
|
|
ttl: 30 * 1000, // millseconds
|
|
max: 1000,
|
|
});
|
|
}
|
|
|
|
async install(options?: InstallOptions) {}
|
|
|
|
async afterEnable() {}
|
|
|
|
async afterDisable() {}
|
|
|
|
async remove() {}
|
|
}
|
|
|
|
export default DataVisualizationPlugin;
|