UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'JTe4XmSsxHofsqnCCSaJZXhfpiNJ+AVMA/+gGVixb44='
WHERE
key_id = 'f163229829a94b5203946e4101935f6179ae638543fa251d7e475bd5ef16b6c1'
AND (
token = 'JTe4XmSsxHofsqnCCSaJZXhfpiNJ+AVMA/+gGVixb44='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)