INSERT INTO wp_tmdb_cache ( movie_id, user_id, tmdb_id, title, original_title, overview, release_date, poster_path, backdrop_path, local_poster_url, tmdb_rating, vote_count, runtime, genres, directors, casts, original_language, production_countries, status, cache_time ) VALUES ( #{data.movieId}, #{data.userId}, #{data.tmdbId}, #{data.title}, #{data.originalTitle}, #{data.overview}, #{data.releaseDate}, #{data.posterPath}, #{data.backdropPath}, #{data.localPosterUrl}, #{data.tmdbRating}, #{data.voteCount}, #{data.runtime}, #{data.genres}, #{data.directors}, #{data.casts}, #{data.originalLanguage}, #{data.productionCountries}, 'active', NOW() ) ON DUPLICATE KEY UPDATE tmdb_id = VALUES(tmdb_id), title = VALUES(title), original_title = VALUES(original_title), overview = VALUES(overview), release_date = VALUES(release_date), poster_path = VALUES(poster_path), backdrop_path = VALUES(backdrop_path), local_poster_url = VALUES(local_poster_url), tmdb_rating = VALUES(tmdb_rating), vote_count = VALUES(vote_count), runtime = VALUES(runtime), genres = VALUES(genres), directors = VALUES(directors), casts = VALUES(casts), original_language = VALUES(original_language), production_countries = VALUES(production_countries), status = 'active', cache_time = NOW() UPDATE wp_tmdb_cache SET status = 'expired' WHERE id IN #{id} DELETE FROM wp_tmdb_cache WHERE movie_id = #{movieId}