UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'W6ekwMXiSAMlO+s+bGnGuQ8UamUJC1dWA+PqI1xKm7o=' 
WHERE 
  key_id = '199da5d79148217fd78a1ffcccfae285d337fb79cc48e9a28613b9aee3051598' 
  AND (
    token = 'W6ekwMXiSAMlO+s+bGnGuQ8UamUJC1dWA+PqI1xKm7o=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00043