Skip to content

Commit

Permalink
Merge pull request #1143 from gustavomm19/vercel-cache
Browse files Browse the repository at this point in the history
Set expire time on vercel cache
  • Loading branch information
alesanchezr authored Oct 10, 2023
2 parents 861a539 + 09236d3 commit d385766
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/pages/api/asset/[assetSlug].js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable consistent-return */
import { kv } from '@vercel/kv';
import bc from '../../../common/services/breathecode';
import { getExtensionName } from '../../../utils';
import { setCacheItem } from '../../../utils/requests';

const BREATHECODE_HOST = process.env.BREATHECODE_HOST || 'https://breathecode-test.herokuapp.com';

Expand Down Expand Up @@ -54,7 +54,7 @@ export default async function handler(req, res) {
asset.markdown = markdown;
asset.ipynbHtml = ipynbHtml;

await kv.set(assetSlug, asset);
await setCacheItem(assetSlug, asset);

res.status(200).json({ message: `${asset.slug} updated` });
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const getCacheItem = async (key) => {
const setCacheItem = async (key, value) => {
try {
console.log(`Setting up ${key} on cache`);
await kv.set(key, value);
await kv.set(key, value, { ex: 604800 }); //Set expire time to one week
} catch (e) {
console.log(`Failed to set ${key} on cache`);
}
Expand Down

0 comments on commit d385766

Please sign in to comment.