Skip to content

FEATURE: Add CompletableFuture append/prepend API#1054

Merged
jhpark816 merged 1 commit intonaver:developfrom
f1v3-dev:feat/v2-append-prepend
Mar 9, 2026
Merged

FEATURE: Add CompletableFuture append/prepend API#1054
jhpark816 merged 1 commit intonaver:developfrom
f1v3-dev:feat/v2-append-prepend

Conversation

@f1v3-dev
Copy link
Collaborator

@f1v3-dev f1v3-dev commented Mar 6, 2026

🔗 Related Issue

⌨️ What I did

  • append, prepend API 구현을 진행했습니다.

구현 특이사항

  • append / prepend는 서버 측에서 raw byte 단위로 값을 이어 붙이는 연산입니다.
  • 서버는 저장된 값의 타입과 관계없이 단순히 기존 바이트 뒤 또는 앞에 새 바이트를 연결합니다.
  • 따라서, String 또는 byte[] 타입의 값에 대해서만 정상 동작하며, 다른 타입에 사용할 경우 문제가 발생합니다.

문제 상황 예시

  • 서버는 바이트 연결 자체는 성공하기 때문에 SUCCESS 를 반환합니다.
  • 클라이언트 또한 연결 자체는 정상 처리로 인식합니다.
  • 하지만, 이후 get(key) 명령을 처리할 때 flag에 기록된 타입 정보와 실제 바이트 구조가 불일치하여 Exception 또는 이상한 값이 발환됩니다.

예시 케이스

기존 값 연산 append 결과 get(key) 결과
"Hello, " (String) append(key, "Arcus!") 성공(SUCCESS) "Hello, Arcus!" (정상 처리)
1 (Integer) append(key, 2) 성공(SUCCESS) 235 (잘못된 값)
"Hello" (String) append(key, 123) 성공(SUCCESS) "Hello " (공백문자 삽입)

@f1v3-dev f1v3-dev requested a review from oliviarla March 6, 2026 09:28
@f1v3-dev f1v3-dev self-assigned this Mar 6, 2026
Copy link
Collaborator

@oliviarla oliviarla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 완료입니다.

ArcusFuture<Boolean> replace(String key, int exp, T value);

/**
* Append to an existing value in the cache.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Append String or byte[] to an existing same type of value.

이러한 설명은 어떤가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다. 설명 내용 변경하도록 하겠습니다.

Comment on lines +181 to +186

Operation op = client.getOpFact()
.cat(catType, 0L, key, co.getData(), cb);

future.setOp(op);
client.addOp(key, op);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 블록에는 줄바꿈이 포함되지 않아도 됩니다.

Comment on lines +188 to +189
.thenAccept(Assertions::assertTrue)
.thenCompose(v -> async.get(key))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전체적으로 이전 테스트들과 일관성을 맞춰주면 좋을 것 같습니다.

  • given -> when -> then 흐름
  • 변수명 (이거는 기존에도 크게 일관성 높지는 않은 것 같음)
  • Future#get 호출 시 timeout 인자 주기 (무한 대기 방지)
  • 여기 블록은 다음과 같이 작성하면 다른 테스트 메서드들과 유사함
    .thenCompose(result -> {
      assertTrue(result);
      return async.get(key);
    })

}

@Test
void testAppendNonStringFail() throws ExecutionException, InterruptedException, TimeoutException {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 메서드도 completablefuture 메서드 사용해 체이닝하는 형태가 되어야 합니다.

@f1v3-dev f1v3-dev force-pushed the feat/v2-append-prepend branch from 6929fe9 to eafac2b Compare March 9, 2026 08:12
@f1v3-dev f1v3-dev force-pushed the feat/v2-append-prepend branch from eafac2b to bbff0a5 Compare March 9, 2026 08:51
@jhpark816 jhpark816 merged commit abcbfa8 into naver:develop Mar 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants