UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'etwharyR8tTqTB+Vrui4DlNQ03mVFATRng/zYYTkgAg=' 
WHERE 
  key_id = '28e7745d1e97b066649b8f1a02dc37dc0d2bff4496ccfadd8b9e843d09ff361d' 
  AND (
    token = 'etwharyR8tTqTB+Vrui4DlNQ03mVFATRng/zYYTkgAg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00047