UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'J2CF9xqRxKriqNRgJVcv61E/caPERD380jOUiM2capU='
WHERE
key_id = '0165d124ec4008491aaff694fc98f0af2999a2bd7a3437b2a1fadc138c49f9d3'
AND (
token = 'J2CF9xqRxKriqNRgJVcv61E/caPERD380jOUiM2capU='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)