UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'UF/fv3Hpd9yh6YfN9ODBNRagsLZovxkwZeDE4Vw2tsY=' 
WHERE 
  key_id = 'cd8f45833424505be7cc069b919a9396143ab236172e6a80f9feee7901646848' 
  AND (
    token = 'UF/fv3Hpd9yh6YfN9ODBNRagsLZovxkwZeDE4Vw2tsY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00023