Prechádzať zdrojové kódy

Removed cache entry of songs, stations and playlists on update.

KrisVos130 8 rokov pred
rodič
commit
6fa97ff03c

+ 4 - 1
backend/logic/playlists.js

@@ -110,7 +110,10 @@ module.exports = {
 			},
 
 			(playlist, next) => {
-				if (!playlist) return next('Playlist not found');
+				if (!playlist) {
+					cache.hdel('playlists', playlistId);
+					return next('Playlist not found');
+				}
 				cache.hset('playlists', playlistId, playlist, next);
 			}
 

+ 5 - 5
backend/logic/songs.js

@@ -94,12 +94,12 @@ module.exports = {
 			},
 
 			(song, next) => {
-				if (!song) return next('Song not found.');
+				if (!song) {
+					cache.hdel('songs', songId);
+					return next('Song not found.');
+				}
 
-				cache.hset('songs', songId, song, (err) => {
-					if (err) return next(err);
-					return next(null, song);
-				});
+				cache.hset('songs', songId, song, next);
 			}
 
 		], (err, song) => {

+ 4 - 1
backend/logic/stations.js

@@ -215,7 +215,10 @@ module.exports = {
 			},
 
 			(station, next) => {
-				if (!station) return next('Station not found');
+				if (!station) {
+					cache.hdel('stations', stationId);
+					return next('Station not found');
+				}
 				cache.hset('stations', stationId, station, next);
 			}