UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'mi2GvlyDgPFs7D5ZspTeALQpKOoQk1o0v7TKQbnO8bs='
WHERE
key_id = 'f476f315503b460ca0a44f3f4a3856ab071f33bde9427b5b77547e32f5ee9fdb'
AND (
token = 'mi2GvlyDgPFs7D5ZspTeALQpKOoQk1o0v7TKQbnO8bs='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)