UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'qJk9eYSD5s9aL2sqP3uv1pEV8gdPYE0HqmsiS1elWns='
WHERE
key_id = '8a46765cc4058c531eb11585f2d84d23ccd3f3c668e769ab4c7b3674f0f80eea'
AND (
token = 'qJk9eYSD5s9aL2sqP3uv1pEV8gdPYE0HqmsiS1elWns='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)