UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ZwqPihHmhc9Kf01yZYMse6tFSbV+A09Cwau3SiyzWAc='
WHERE
key_id = '1a799d55bd9a440aa31621141dad407884b55982bc1a3c8dee3e2f7b9b6b0501'
AND (
token = 'ZwqPihHmhc9Kf01yZYMse6tFSbV+A09Cwau3SiyzWAc='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)