tachybase_todo/packages/plugins/@nocobase/plugin-data-visualization/src/server/plugin.ts
YANG QIA daac2ae0db
refactor(cache): improve cache (#3004)
* 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
2023-11-20 17:14:20 +08:00

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;