前提
プログラミング初心者で、javaとSpring Frameworkを学習しております。TwitterのようなサンプルアプリであるRetwis-Jを元にRedisがどのようなデータ構造を持つのかを説明するDocで1.4.2 Persistenceに出てきた、コードが読み下せず、どのような処理をしているのかどこを参照すれば理解に至れそうなのか教えていただきたいです。
(追記)リンクが抜けておりました、失礼しました。
https://docs.spring.io/spring-data/data-keyvalue/examples/retwisj/current/#retwisj:design:persistence
お伺いしたいこと
・下記コードを理解したいです
Java
1private RedisSet<String> following(String uid) { 2 return new DefaultRedisSet<String>(KeyUtils.following(uid), template); 3} 4 5public Collection<String> commonFollowers(String uid, String targetUid) { 6 RedisSet<String> tempSet = following(uid). 7 intersectAndStore(following(targetUid), 8 KeyUtils.commonFollowers(uid, targetUid)); 9 10 tempSet.expire(5, TimeUnit.SECONDS); 11 12 return covertUidsToNames(tempSet.getKey()); 13}
・理解していること(理解していると思っていること)
- followingというオブジェクトを定義している
- commonFollowersというオブジェクトを定義している
- tempSet.expireは時間かかりすぎないようにタイムアウトを起こさせるためのメソッド
・具体的に分からないポイントは
- ”KeyUtils”が何なのか、その配下のメソッドが具体的にどういう処理を行うものなのか分からない
- commonFollowersのメソッドの改行がどこなのか分からない(下記のような1行を可読性のため改行しているだけで、実質はtempSetに、following.intersectAndStoreのメソッドの実行結果を代入しているだけ?)
Java
1tempSet = following(uid).intersectAndStore(following(targetUid),KeyUtils.commonFollowers(uid, targetUid));
以上よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/10/09 01:37