UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'iZ6y2iy6osPr/Mqf0WfgUBtOKPyT2/H2iTMXyvpZ9xg=' 
WHERE 
  key_id = '326e187a93d7d250529bb6e52d27a823bcfbca47e2ae9031c31eda14cad72599' 
  AND (
    token = 'iZ6y2iy6osPr/Mqf0WfgUBtOKPyT2/H2iTMXyvpZ9xg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032