UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'sNwFYJeyzpoYoXYNS0hEkX1kO0yujsCj/3kxrRUMGDw='
WHERE
key_id = '318477bb37a4aa29fa68fd25716057e0319bdec4a39ba7e3497a10317a4dc054'
AND (
token = 'sNwFYJeyzpoYoXYNS0hEkX1kO0yujsCj/3kxrRUMGDw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)