@@ -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);
}
@@ -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) => {
@@ -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);