0.0.1 • Published 11 months ago

@rizom/cache v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

Cache plugin for rizom CMS

Use

// src/config/rizom.config.ts
import { cache } from '@rizom/cache';

const config: Config = {
  //...config
  plugins: [cache({ enabled: true })]
};

export default config;

Get and set cache

import { type ServerLoadEvent } from '@sveltejs/kit';
import type { PagesDoc } from '../app.generated.js';

export const load = async (event: ServerLoadEvent) => {
  const { api, rizom } = event.locals;

  const docs = await rizom.plugins.cache.get<PagesDoc[]>(
    'pages',
    api.collection('pages').findAll
  );

  return { docs };
};

Clear cache

In event handlers

import { type ServerLoadEvent } from '@sveltejs/kit';

export const load = async (event: ServerLoadEvent) => {
  const { rizom } = event.locals;

  await rizom.plugins.cache.clear()

  //...
};

Routes

  • POST : /api/clear-cache
0.0.1

11 months ago

0.0.0

11 months ago