UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'vdAQsotqZSkjTFAvH4ETvgNOtbX5G6q6G7Ym06EB+9k='
WHERE
key_id = '77389f0b126f28a93166c3d28255c205ac80df2d8947409182cc6860021a9254'
AND (
token = 'vdAQsotqZSkjTFAvH4ETvgNOtbX5G6q6G7Ym06EB+9k='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)