Skip to content

Commit

Permalink
delete cache when duplicateTour
Browse files Browse the repository at this point in the history
  • Loading branch information
augustus281 committed May 17, 2024
1 parent dfd48f5 commit 3880cbd
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions server/src/controllers/tour.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ const UserTour = require("../models/user_tour.model")
const User = require("../models/user.model")
const redis = require("redis")

const slugify = (text) => {
return text.toString().toLowerCase()
.replace(/\s+/g, '-')
.replace(/[^\w\-]+/g, '')

.replace(/\-\-+/g, '-')
.replace(/^-+/, '')
.replace(/-+$/, '');
};

let redisClient;
(async () => {
redisClient = redis.createClient();
Expand Down Expand Up @@ -155,6 +145,8 @@ class TourController {
try {
const newTour = await duplicateTour(tour_id)
if (!newTour) return res.status(400).json({ message: "Failed to copy tour!" })

redisClient.delete("waiting_tours")
return res.status(201).json({
message: "Copy tour successfully!",
data: newTour
Expand Down

0 comments on commit 3880cbd

Please sign in to comment.