UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'nMzNqauuHawOgTm6IhYytB/KZZzJyPIDJELaPTyANnM=' 
WHERE 
  key_id = 'f451c1c21f4cc8de853093433b3941ddd2505ba788383f8d67829a51d3d72c3d' 
  AND (
    token = 'nMzNqauuHawOgTm6IhYytB/KZZzJyPIDJELaPTyANnM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037