UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'S2Fz01iIx6hOlmNFz1KM0WyUcnVu6sSaFiqEI8hiIzo=' 
WHERE 
  key_id = '24fb264b89b907344e180954078d7dc40a6431ed097f98803afeb3bee03b4b2e' 
  AND (
    token = 'S2Fz01iIx6hOlmNFz1KM0WyUcnVu6sSaFiqEI8hiIzo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031