UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'tBDvVW7CgUb2RUZuYr9hChB+dSnxTE1lMwN0psfPTrk='
WHERE
key_id = '1c31f5d77f539fc716fd4fbef5158ca15b161c41a42bdb19f99d68c7c4b4f1c8'
AND (
token = 'tBDvVW7CgUb2RUZuYr9hChB+dSnxTE1lMwN0psfPTrk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)