UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'QloPegcyCKtygyt4VaoItc4+DesF3O7llWz+sH+ZgIw=' 
WHERE 
  key_id = '3fac45ab941da7cf0493588fc9349614929d813d9138571cc5a5fb688c9c2e94' 
  AND (
    token = 'QloPegcyCKtygyt4VaoItc4+DesF3O7llWz+sH+ZgIw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00049