โฌ‡๏ธ Main Note
https://docs.google.com/document/d/1Ce2r1obYEdFcmE1S8LLDWiZJbWWA0V6iE_wj4J9802k/edit


Mostly backend computer takes a big role in searching. Once the frontend computer requsts for searching a word, the backend copmuter responses with the wanted word. then frontend receives it and displays to the screen.


๐Ÿ”ง Types of Database

Full Table Scan

: This database scans the whole thing.

  • ex) When the user is using searching method to look up for the posts that contain "Italy", full table scan database is scanning all the millions of posts.
  • It's inefficient way to do so.
  • Disk based database

So to make sure the program runs in an efficient way, elastic search database can be used.

  • Inside the database, the words are separated as tokens in the table.
    --> ex) "Hello Word" => Hello World
  • Then the words of row are saved as a number so that the user can take out that specific number of row, which contains same words.
  • Each words are seen as tokens, so this database action is called as tokenizing.
  • This is way much faster.
  • Disk based database

Redis

  • High traffic === High connection volume
    --> More the traffic goes higher, more the searching keywords overlap.
  • When things start to overlap much, new database is created: Reis.
  • In this database, the searching keywords are saved in the table.
  • "Cashing in redis" => Temporally save the keyword.
  • Memory based database
    --> Fast

Disk based vs. Memory based

Memory based: Temporal saving.
--> Once the computer is shut down, all the data are gone.
--> Fast since it doesn't have to permanently save everything.
(์ผ๋‹จ ์งฑ๋ฐ•์•„๋‘๋Š” ๊ฐœ๋…)

Disk based: Permanent saving.
--> Doesn't get deleted even when the computer is shut down.
--> Slow since it has to save the data safely.
(๋””์Šคํฌ ์ž์ฒด์— ์ €์žฅ)


๐Ÿ•“ Debouncing vs. Throttle

Debouncing

  • Operated when the user doesn't make any changes in input box for particular seconds.
  • The user can assign the time.
    ex) 10 sec --> 10000
    Then 10 secs after making a change in input box, the request is sent.

Throttle

  • Opposite concept of debouncing.
  • Operated at the very first time when the browser is executed. After it is operated, for the assigned time, it doesn't send any request.
  • ex) One scrolling literally looks like is is only scrolled once, but it is actually scrolled for millions of scrollings.
    --> To prevent million times of execution, throttle exists.

๐Ÿ‘“ [Lodash]

  • underbar is used as variables. _
  • setTimeout: Function is executed after the particular time
    --> Debounce is used here.

๐Ÿฅฝ [Secret Code]

  • #$%
    --> This might be much more complex since some users might accidentally type this.
    --> But for here, used #$% just for instance.
  • So spliting the sentence in 3 values and save it inside the array.
  • replaceAll -> split -> map

๐Ÿ‘Ÿ [Algorithms - Euclidean algorithm]

//์œ ํด๋ฆฌ๋“œ ํ˜ธ์žฌ๋ฒ• => ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜๋ฅผ ๊ตฌํ•˜๊ธฐ ์œ„ํ•œ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ณต์‹

//ํฐ ์ˆ˜๋ฅผ ์ž‘์€ ์ˆ˜๋กœ ๋‚˜๋ˆด์„๋•Œ (a๊ฐ€ ํฐ ์ˆ˜์ด๊ณ  b๊ฐ€ ์ž‘์€์ˆ˜๋ผ๋ฉด --> a๋ฅผ b๋กœ ๋‚˜๋ˆˆ๋‹ค.)
//๋‚˜๋จธ์ง€ ๊ฐ’์ด 6์ด ๋˜๋ฉด ๋‚˜๋ˆด๋˜ ์ž‘์€ ์ˆ˜ b๊ฐ€ ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜๊ฐ€ ๋œ๋‹ค
//๋‚˜๋จธ์ง€ ๊ฐ’์ด 0์ด ๋  ๋•Œ๊นŒ์ง€ ๊ณ„์† ๋ฐ˜๋ณต
//๋‚˜๋จธ์ง€๊ฐ€ 0์ด ๋˜๋ฉด, ๋‚˜๋ˆด๋˜ ์ž‘์€ ์ˆ˜ b๊ฐ€ ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜๊ฐ€ ๋œ๋‹ค

function solution(n, m) {
  let a = m; //ํฐ ์ˆ˜๊ฐ€ ๋“ค์–ด์˜จ๋‹ค
  let b = n; //์ž‘์€ ์ˆ˜๊ฐ€ ๋“ค์–ด์˜จ๋‹ค
  let r = 0; //a๋ฅผ b๋กœ ๋‚˜๋ˆด์„ ๋•Œ์˜ ๋‚˜๋จธ์ง€ ๊ฐ’

  while (a % b > 0) {
    r = a % b;
    a = b; //ํฐ ์ˆ˜์— ์ž‘์€ ์ˆ˜๋ฅผ ํ• ๋‹น
    b = r; //์ž‘์€ ์ˆ˜์—๋Š” ๋‚˜๋จธ์ง€ ๊ฐ’ ํ• ๋‹น
  }

  //์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜: n๊ณผ m์„ ๊ณฑํ•œ ๊ฐ’์— ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜๋ฅผ ๋‚˜๋ˆ„๋ฉด ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜๊ฐ€ ๋œ๋‹ค
  return [b, (n * m) / b];
}
profile
์ฝฑใ…†l

0๊ฐœ์˜ ๋Œ“๊ธ€