UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'P4A+Ycu9vJaE+dxzO7iShCNaspJ2w9kwdeX/wtvyqng=' 
WHERE 
  key_id = '338c593d000b765a759413a3f24ee33c14093e675551adaa0449beaa1eab0ef9' 
  AND (
    token = 'P4A+Ycu9vJaE+dxzO7iShCNaspJ2w9kwdeX/wtvyqng=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034