UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'S7pNTcF+co6X98i5hI/s10SLeaeFaJ1tuzzfaZ7yFzQ=' 
WHERE 
  key_id = 'da20b2693f09046e2a009fedd0b2c4057c2e8cd4d3e30b05e06b4c3cacae49d1' 
  AND (
    token = 'S7pNTcF+co6X98i5hI/s10SLeaeFaJ1tuzzfaZ7yFzQ=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035