【DB設計・実装】redisの機能tips

### 背景
redisの機能を確認するため

---

### 内容

#### <b>サーバとクライアント、アーキテクチャ</b>

---

#### <b>publishとsubscribeについて</b>
* チャネル
    * 
* Publish（出版者）
    * コマンドは、「PUBLISH チャンネル名 内容」
    * Subscribeしているクライアントからデータが届く
* Subscribe（購読者）
    * コマンドは、「SUBSCRIBE チャンネル名」
    * 一度発行するとRedisにつながったまま
* 参考URL
    * https://qiita.com/satofujino/items/7bf4b99e2176f63ca7ef
    * https://qiita.com/jkr_2255/items/6ae9e5e2244052e41369

---

##### スクリプト
<pre>
#!/bin/bash
apt update
apt upgrade
apt install redis-server
nohup redis-server > aaa.out &
redis-cli ping >> publish_subscribe_test.log
redis-cli publish unko testmessage >> publish_subscribe_test.log
echo =======subscribe_success_1st======= >> publish_subscribe_test.log
nohup redis-cli subscribe unko >> publish_subscribe_test.log &
echo =======subscribe_fail_1st======= >> publish_subscribe_test.log
nohup redis-cli subscribe nohoge >> publish_subscribe_test.log &
echo =======publish_part2======= >> publish_subscribe_test.log
redis-cli publish unko testmessagepart2 >> publish_subscribe_test.log
echo =======publish_part3======= >> publish_subscribe_test.log
redis-cli publish unko testmessagepart3 >> publish_subscribe_test.log
echo =======publish_part4======= >> publish_subscribe_test.log
redis-cli publish unko testmessagepart4 >> publish_subscribe_test.log
echo =======publish_part5======= >> publish_subscribe_test.log
redis-cli publish unko testmessagepart5 >> publish_subscribe_test.log
echo =======subscribe_success_final======= >> publish_subscribe_test.log
nohup redis-cli subscribe unko >> publish_subscribe_test.log &
echo =======pubsub_channel_lists======= >> publish_subscribe_test.log
redis-cli pubsub channels >> publish_subscribe_test.log
echo =======pubsub_nums_channel_lists======= >> publish_subscribe_test.log
redis-cli pubsub numsub unko >> publish_subscribe_test.log
redis-cli LATEST-MESSAGE unko >> publish_subscribe_test.log
redis-cli pubsub numsub nohoge >> publish_subscribe_test.log
echo =======final_redis_ping======= >> publish_subscribe_test.log
redis-cli ping >> publish_subscribe_test.log
echo =======unsubscribe======= >> publish_subscribe_test.log
nohup redis-cli unsubscribe unko >> publish_subscribe_test.log &
</pre>

---

##### 権限変更
`
chmod 755 redis_test.sh
`
`
ls -lrt redis_test.sh
`
* 出力例
```
-rwxr-xr-x 1 root root 1830 Mar  3 02:08 redis_test.sh
```

##### スクリプトの実行

`
/bin/bash redis_test.sh > result.log
`

```
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.


WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Extracting templates from packages: 100%

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

nohup: redirecting stderr to stdout
Could not connect to Redis at 127.0.0.1:6379: Connection refused
nohup: redirecting stderr to stdout
nohup: nohup: redirecting stderr to stdout
redirecting stderr to stdout
nohup: redirecting stderr to stdout
nohup: redirecting stderr to stdout
```
##### スクリプト実行結果のログ
`
ls -l ; cat result.log
`

```
total 44
-rw-r--r-- 1 root root   548 Mar  3 08:12 aaa.out
-rw-r--r-- 1 root root   658 Mar  3 08:12 publish_subscribe_test.log
-rwxr-xr-x 1 root root  1742 Mar  3 08:12 redis_test.sh
-rw-r--r-- 1 root root 27702 Mar  3 08:12 result.log
drwxr-xr-x 1 root root  4096 Feb 28 14:27 sample_data
Get:1 https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/ InRelease [3,626 B]
Hit:2 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64  InRelease
Get:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:4 https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/ Packages [50.4 kB]
Hit:5 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:6 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Hit:7 https://ppa.launchpadcontent.net/c2d4u.team/c2d4u4.0+/ubuntu jammy InRelease
Hit:8 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy InRelease
Get:9 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [1,517 kB]
Hit:10 https://ppa.launchpadcontent.net/graphics-drivers/ppa/ubuntu jammy InRelease
Hit:11 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:12 https://ppa.launchpadcontent.net/ubuntugis/ppa/ubuntu jammy InRelease
Get:13 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1,796 kB]
Get:14 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [1,074 kB]
Get:15 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [1,346 kB]
Fetched 6,017 kB in 2s (2,729 kB/s)
Reading package lists...
Building dependency tree...
Reading state information...
40 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
The following packages have been kept back:
  libcudnn8 libcudnn8-dev libnccl-dev libnccl2
The following packages will be upgraded:
  base-files binutils binutils-common binutils-x86-64-linux-gnu coreutils cuda-compat-12-2
  cuda-keyring cuda-toolkit-12-config-common cuda-toolkit-config-common libbinutils libc-bin
  libctf-nobfd0 libctf0 libgnutls30 libldap-2.5-0 libpam-modules libpam-modules-bin libpam-runtime
  libpam0g libperl5.34 libprocps8 libudev1 linux-libc-dev login openssl passwd perl perl-base
  perl-modules-5.34 procps r-base r-base-core r-base-dev r-recommended tar tzdata
36 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
Need to get 82.5 MB of archives.
After this operation, 77.8 kB of additional disk space will be used.
Get:1 https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/ r-base-core 4.3.3-1.2204.0 [27.2 MB]
Get:2 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64  cuda-compat-12-2 535.161.07-1 [33.6 MB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 base-files amd64 12ubuntu4.6 [62.5 kB]
Get:4 https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/ r-base 4.3.3-1.2204.0 [46.5 kB]
Get:5 https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/ r-recommended 4.3.3-1.2204.0 [2,590 B]
Get:6 https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/ r-base-dev 4.3.3-1.2204.0 [4,292 B]
Get:7 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 coreutils amd64 8.32-4.1ubuntu1.1 [1,436 kB]
Get:8 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64  cuda-keyring 1.1-1 [4,332 B]
Get:9 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64  cuda-toolkit-12-config-common 12.3.101-1 [16.4 kB]
Get:10 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64  cuda-toolkit-config-common 12.3.101-1 [16.4 kB]
Get:11 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 login amd64 1:4.8.1-2ubuntu2.2 [188 kB]
Get:12 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libperl5.34 amd64 5.34.0-3ubuntu1.3 [4,820 kB]
Get:13 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 perl amd64 5.34.0-3ubuntu1.3 [232 kB]
Get:14 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 perl-base amd64 5.34.0-3ubuntu1.3 [1,762 kB]
Get:15 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 perl-modules-5.34 all 5.34.0-3ubuntu1.3 [2,976 kB]
Get:16 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 tar amd64 1.34+dfsg-1ubuntu0.1.22.04.2 [295 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libc-bin amd64 2.35-0ubuntu3.6 [706 kB]
Get:18 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpam0g amd64 1.4.0-11ubuntu2.4 [60.2 kB]
Get:19 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpam-modules-bin amd64 1.4.0-11ubuntu2.4 [37.6 kB]
Get:20 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpam-modules amd64 1.4.0-11ubuntu2.4 [280 kB]
Get:21 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpam-runtime all 1.4.0-11ubuntu2.4 [40.3 kB]
Get:22 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libudev1 amd64 249.11-0ubuntu3.12 [78.2 kB]
Get:23 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 passwd amd64 1:4.8.1-2ubuntu2.2 [768 kB]
Get:24 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libgnutls30 amd64 3.7.3-4ubuntu1.4 [969 kB]
Get:25 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libprocps8 amd64 2:3.3.17-6ubuntu2.1 [36.2 kB]
Get:26 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 procps amd64 2:3.3.17-6ubuntu2.1 [378 kB]
Get:27 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 openssl amd64 3.0.2-0ubuntu1.15 [1,186 kB]
Get:28 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 tzdata all 2024a-0ubuntu0.22.04 [348 kB]
Get:29 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libctf0 amd64 2.38-4ubuntu2.6 [103 kB]
Get:30 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libctf-nobfd0 amd64 2.38-4ubuntu2.6 [108 kB]
Get:31 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 binutils-x86-64-linux-gnu amd64 2.38-4ubuntu2.6 [2,326 kB]
Get:32 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libbinutils amd64 2.38-4ubuntu2.6 [662 kB]
Get:33 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 binutils amd64 2.38-4ubuntu2.6 [3,200 B]
Get:34 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 binutils-common amd64 2.38-4ubuntu2.6 [222 kB]
Get:35 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libldap-2.5-0 amd64 2.5.16+dfsg-0ubuntu0.22.04.2 [183 kB]
Get:36 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 linux-libc-dev amd64 5.15.0-97.107 [1,325 kB]
Preconfiguring packages ...
Fetched 82.5 MB in 5s (17.6 MB/s)
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../base-files_12ubuntu4.6_amd64.deb ...
Unpacking base-files (12ubuntu4.6) over (12ubuntu4.4) ...
Setting up base-files (12ubuntu4.6) ...
Installing new version of config file /etc/issue ...
Installing new version of config file /etc/issue.net ...
Installing new version of config file /etc/lsb-release ...
Installing new version of config file /etc/update-motd.d/10-help-text ...
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../coreutils_8.32-4.1ubuntu1.1_amd64.deb ...
Unpacking coreutils (8.32-4.1ubuntu1.1) over (8.32-4.1ubuntu1) ...
Setting up coreutils (8.32-4.1ubuntu1.1) ...
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../login_1%3a4.8.1-2ubuntu2.2_amd64.deb ...
Unpacking login (1:4.8.1-2ubuntu2.2) over (1:4.8.1-2ubuntu2.1) ...
Setting up login (1:4.8.1-2ubuntu2.2) ...
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../libperl5.34_5.34.0-3ubuntu1.3_amd64.deb ...
Unpacking libperl5.34:amd64 (5.34.0-3ubuntu1.3) over (5.34.0-3ubuntu1.2) ...
Preparing to unpack .../perl_5.34.0-3ubuntu1.3_amd64.deb ...
Unpacking perl (5.34.0-3ubuntu1.3) over (5.34.0-3ubuntu1.2) ...
Preparing to unpack .../perl-base_5.34.0-3ubuntu1.3_amd64.deb ...
Unpacking perl-base (5.34.0-3ubuntu1.3) over (5.34.0-3ubuntu1.2) ...
Setting up perl-base (5.34.0-3ubuntu1.3) ...
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../perl-modules-5.34_5.34.0-3ubuntu1.3_all.deb ...
Unpacking perl-modules-5.34 (5.34.0-3ubuntu1.3) over (5.34.0-3ubuntu1.2) ...
Preparing to unpack .../tar_1.34+dfsg-1ubuntu0.1.22.04.2_amd64.deb ...
Unpacking tar (1.34+dfsg-1ubuntu0.1.22.04.2) over (1.34+dfsg-1ubuntu0.1.22.04.1) ...
Setting up tar (1.34+dfsg-1ubuntu0.1.22.04.2) ...
update-alternatives: warning: forcing reinstallation of alternative /usr/sbin/rmt-tar because link group rmt is broken
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../libc-bin_2.35-0ubuntu3.6_amd64.deb ...
Unpacking libc-bin (2.35-0ubuntu3.6) over (2.35-0ubuntu3.4) ...
Setting up libc-bin (2.35-0ubuntu3.6) ...
/sbin/ldconfig.real: /usr/local/lib/libtbb.so.12 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbbind.so.3 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_0.so.3 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbmalloc.so.2 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbmalloc_proxy.so.2 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_5.so.3 is not a symbolic link

(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../libpam0g_1.4.0-11ubuntu2.4_amd64.deb ...
Unpacking libpam0g:amd64 (1.4.0-11ubuntu2.4) over (1.4.0-11ubuntu2.3) ...
Setting up libpam0g:amd64 (1.4.0-11ubuntu2.4) ...
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../libpam-modules-bin_1.4.0-11ubuntu2.4_amd64.deb ...
Unpacking libpam-modules-bin (1.4.0-11ubuntu2.4) over (1.4.0-11ubuntu2.3) ...
Setting up libpam-modules-bin (1.4.0-11ubuntu2.4) ...
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../libpam-modules_1.4.0-11ubuntu2.4_amd64.deb ...
Unpacking libpam-modules:amd64 (1.4.0-11ubuntu2.4) over (1.4.0-11ubuntu2.3) ...
Setting up libpam-modules:amd64 (1.4.0-11ubuntu2.4) ...
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../libpam-runtime_1.4.0-11ubuntu2.4_all.deb ...
Unpacking libpam-runtime (1.4.0-11ubuntu2.4) over (1.4.0-11ubuntu2.3) ...
Setting up libpam-runtime (1.4.0-11ubuntu2.4) ...
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../libudev1_249.11-0ubuntu3.12_amd64.deb ...
Unpacking libudev1:amd64 (249.11-0ubuntu3.12) over (249.11-0ubuntu3.10) ...
Setting up libudev1:amd64 (249.11-0ubuntu3.12) ...
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../passwd_1%3a4.8.1-2ubuntu2.2_amd64.deb ...
Unpacking passwd (1:4.8.1-2ubuntu2.2) over (1:4.8.1-2ubuntu2.1) ...
Setting up passwd (1:4.8.1-2ubuntu2.2) ...
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../libgnutls30_3.7.3-4ubuntu1.4_amd64.deb ...
Unpacking libgnutls30:amd64 (3.7.3-4ubuntu1.4) over (3.7.3-4ubuntu1.2) ...
Setting up libgnutls30:amd64 (3.7.3-4ubuntu1.4) ...
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../00-libprocps8_2%3a3.3.17-6ubuntu2.1_amd64.deb ...
Unpacking libprocps8:amd64 (2:3.3.17-6ubuntu2.1) over (2:3.3.17-6ubuntu2) ...
Preparing to unpack .../01-procps_2%3a3.3.17-6ubuntu2.1_amd64.deb ...
Unpacking procps (2:3.3.17-6ubuntu2.1) over (2:3.3.17-6ubuntu2) ...
Preparing to unpack .../02-openssl_3.0.2-0ubuntu1.15_amd64.deb ...
Unpacking openssl (3.0.2-0ubuntu1.15) over (3.0.2-0ubuntu1.12) ...
Preparing to unpack .../03-tzdata_2024a-0ubuntu0.22.04_all.deb ...
Unpacking tzdata (2024a-0ubuntu0.22.04) over (2023d-0ubuntu0.22.04) ...
Preparing to unpack .../04-libctf0_2.38-4ubuntu2.6_amd64.deb ...
Unpacking libctf0:amd64 (2.38-4ubuntu2.6) over (2.38-4ubuntu2.3) ...
Preparing to unpack .../05-libctf-nobfd0_2.38-4ubuntu2.6_amd64.deb ...
Unpacking libctf-nobfd0:amd64 (2.38-4ubuntu2.6) over (2.38-4ubuntu2.3) ...
Preparing to unpack .../06-binutils-x86-64-linux-gnu_2.38-4ubuntu2.6_amd64.deb ...
Unpacking binutils-x86-64-linux-gnu (2.38-4ubuntu2.6) over (2.38-4ubuntu2.3) ...
Preparing to unpack .../07-libbinutils_2.38-4ubuntu2.6_amd64.deb ...
Unpacking libbinutils:amd64 (2.38-4ubuntu2.6) over (2.38-4ubuntu2.3) ...
Preparing to unpack .../08-binutils_2.38-4ubuntu2.6_amd64.deb ...
Unpacking binutils (2.38-4ubuntu2.6) over (2.38-4ubuntu2.3) ...
Preparing to unpack .../09-binutils-common_2.38-4ubuntu2.6_amd64.deb ...
Unpacking binutils-common:amd64 (2.38-4ubuntu2.6) over (2.38-4ubuntu2.3) ...
Preparing to unpack .../10-cuda-compat-12-2_535.161.07-1_amd64.deb ...
Unpacking cuda-compat-12-2 (535.161.07-1) over (535.129.03-1) ...
Preparing to unpack .../11-cuda-keyring_1.1-1_all.deb ...
Unpacking cuda-keyring (1.1-1) over (1.0-1) ...
Preparing to unpack .../12-cuda-toolkit-12-config-common_12.3.101-1_all.deb ...
Unpacking cuda-toolkit-12-config-common (12.3.101-1) over (12.3.52-1) ...
Preparing to unpack .../13-cuda-toolkit-config-common_12.3.101-1_all.deb ...
Unpacking cuda-toolkit-config-common (12.3.101-1) over (12.3.52-1) ...
Preparing to unpack .../14-libldap-2.5-0_2.5.16+dfsg-0ubuntu0.22.04.2_amd64.deb ...
Unpacking libldap-2.5-0:amd64 (2.5.16+dfsg-0ubuntu0.22.04.2) over (2.5.16+dfsg-0ubuntu0.22.04.1) ...
Preparing to unpack .../15-linux-libc-dev_5.15.0-97.107_amd64.deb ...
Unpacking linux-libc-dev:amd64 (5.15.0-97.107) over (5.15.0-88.98) ...
Preparing to unpack .../16-r-base-core_4.3.3-1.2204.0_amd64.deb ...
Unpacking r-base-core (4.3.3-1.2204.0) over (4.3.2-1.2204.0) ...
Preparing to unpack .../17-r-base_4.3.3-1.2204.0_all.deb ...
Unpacking r-base (4.3.3-1.2204.0) over (4.3.2-1.2204.0) ...
Preparing to unpack .../18-r-recommended_4.3.3-1.2204.0_all.deb ...
Unpacking r-recommended (4.3.3-1.2204.0) over (4.3.2-1.2204.0) ...
Preparing to unpack .../19-r-base-dev_4.3.3-1.2204.0_all.deb ...
Unpacking r-base-dev (4.3.3-1.2204.0) over (4.3.2-1.2204.0) ...
Setting up cuda-toolkit-config-common (12.3.101-1) ...
Setting up cuda-compat-12-2 (535.161.07-1) ...
Setting up binutils-common:amd64 (2.38-4ubuntu2.6) ...
Setting up linux-libc-dev:amd64 (5.15.0-97.107) ...
Setting up libctf-nobfd0:amd64 (2.38-4ubuntu2.6) ...
Setting up perl-modules-5.34 (5.34.0-3ubuntu1.3) ...
Setting up libldap-2.5-0:amd64 (2.5.16+dfsg-0ubuntu0.22.04.2) ...
Setting up tzdata (2024a-0ubuntu0.22.04) ...

Current default time zone: 'Etc/UTC'
Local time is now:      Sun Mar  3 08:12:03 UTC 2024.
Universal Time is now:  Sun Mar  3 08:12:03 UTC 2024.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

Setting up cuda-keyring (1.1-1) ...
Setting up r-base-core (4.3.3-1.2204.0) ...
Installing new version of config file /etc/R/Makeconf ...
Setting up libbinutils:amd64 (2.38-4ubuntu2.6) ...
Setting up openssl (3.0.2-0ubuntu1.15) ...
Setting up cuda-toolkit-12-config-common (12.3.101-1) ...
Setting up r-recommended (4.3.3-1.2204.0) ...
Setting up libprocps8:amd64 (2:3.3.17-6ubuntu2.1) ...
Setting up libctf0:amd64 (2.38-4ubuntu2.6) ...
Setting up libperl5.34:amd64 (5.34.0-3ubuntu1.3) ...
Setting up r-base-dev (4.3.3-1.2204.0) ...
Setting up perl (5.34.0-3ubuntu1.3) ...
Setting up r-base (4.3.3-1.2204.0) ...
Setting up procps (2:3.3.17-6ubuntu2.1) ...
Setting up binutils-x86-64-linux-gnu (2.38-4ubuntu2.6) ...
Setting up binutils (2.38-4ubuntu2.6) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
/sbin/ldconfig.real: /usr/local/lib/libtbb.so.12 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbbind.so.3 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_0.so.3 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbmalloc.so.2 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbmalloc_proxy.so.2 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_5.so.3 is not a symbolic link

Processing triggers for man-db (2.10.2-1) ...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  libjemalloc2 liblua5.1-0 liblzf1 lua-bitop lua-cjson redis-tools
Suggested packages:
  ruby-redis
The following NEW packages will be installed:
  libjemalloc2 liblua5.1-0 liblzf1 lua-bitop lua-cjson redis-server redis-tools
0 upgraded, 7 newly installed, 0 to remove and 4 not upgraded.
Need to get 1,273 kB of archives.
After this operation, 5,725 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu jammy/universe amd64 libjemalloc2 amd64 5.2.1-4ubuntu1 [240 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy/universe amd64 liblua5.1-0 amd64 5.1.5-8.1build4 [99.9 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy/universe amd64 liblzf1 amd64 3.6-3 [7,444 B]
Get:4 http://archive.ubuntu.com/ubuntu jammy/universe amd64 lua-bitop amd64 1.0.2-5 [6,680 B]
Get:5 http://archive.ubuntu.com/ubuntu jammy/universe amd64 lua-cjson amd64 2.1.0+dfsg-2.1 [17.4 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy/universe amd64 redis-tools amd64 5:6.0.16-1ubuntu1 [856 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy/universe amd64 redis-server amd64 5:6.0.16-1ubuntu1 [45.9 kB]
Fetched 1,273 kB in 1s (1,915 kB/s)
Selecting previously unselected package libjemalloc2:amd64.
(Reading database ... 121749 files and directories currently installed.)
Preparing to unpack .../0-libjemalloc2_5.2.1-4ubuntu1_amd64.deb ...
Unpacking libjemalloc2:amd64 (5.2.1-4ubuntu1) ...
Selecting previously unselected package liblua5.1-0:amd64.
Preparing to unpack .../1-liblua5.1-0_5.1.5-8.1build4_amd64.deb ...
Unpacking liblua5.1-0:amd64 (5.1.5-8.1build4) ...
Selecting previously unselected package liblzf1:amd64.
Preparing to unpack .../2-liblzf1_3.6-3_amd64.deb ...
Unpacking liblzf1:amd64 (3.6-3) ...
Selecting previously unselected package lua-bitop:amd64.
Preparing to unpack .../3-lua-bitop_1.0.2-5_amd64.deb ...
Unpacking lua-bitop:amd64 (1.0.2-5) ...
Selecting previously unselected package lua-cjson:amd64.
Preparing to unpack .../4-lua-cjson_2.1.0+dfsg-2.1_amd64.deb ...
Unpacking lua-cjson:amd64 (2.1.0+dfsg-2.1) ...
Selecting previously unselected package redis-tools.
Preparing to unpack .../5-redis-tools_5%3a6.0.16-1ubuntu1_amd64.deb ...
Unpacking redis-tools (5:6.0.16-1ubuntu1) ...
Selecting previously unselected package redis-server.
Preparing to unpack .../6-redis-server_5%3a6.0.16-1ubuntu1_amd64.deb ...
Unpacking redis-server (5:6.0.16-1ubuntu1) ...
Setting up libjemalloc2:amd64 (5.2.1-4ubuntu1) ...
Setting up lua-cjson:amd64 (2.1.0+dfsg-2.1) ...
Setting up liblzf1:amd64 (3.6-3) ...
Setting up lua-bitop:amd64 (1.0.2-5) ...
Setting up liblua5.1-0:amd64 (5.1.5-8.1build4) ...
Setting up redis-tools (5:6.0.16-1ubuntu1) ...
Setting up redis-server (5:6.0.16-1ubuntu1) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Created symlink /etc/systemd/system/redis.service → /lib/systemd/system/redis-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/redis-server.service → /lib/systemd/system/redis-server.service.
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
/sbin/ldconfig.real: /usr/local/lib/libtbb.so.12 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbbind.so.3 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_0.so.3 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbmalloc.so.2 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbmalloc_proxy.so.2 is not a symbolic link

/sbin/ldconfig.real: /usr/local/lib/libtbbbind_2_5.so.3 is not a symbolic link

```

##### redis-server起動ログ
`
cat aaa.out
`
```
2390:C 03 Mar 2024 08:12:11.602 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2390:C 03 Mar 2024 08:12:11.602 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=2390, just started
2390:C 03 Mar 2024 08:12:11.602 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
2390:M 03 Mar 2024 08:12:11.604 * Running mode=standalone, port=6379.
2390:M 03 Mar 2024 08:12:11.604 # Server initialized
2390:M 03 Mar 2024 08:12:11.604 * Ready to accept connections
```
##### publish、subscribe時のログ
`
cat publish_subscribe_test.log
`
publish_part3で、nohogeはpublishしていないのにもかかわらず、
なぜsubscribeでnohogeを取得しようとしているのかがよくわからない・・・
```
=======subscribe_success_1st=======
=======subscribe_fail_1st=======
=======subscribe_fail_2nd=======
=======publish_part2=======
=======subscribe_success_1st=======
=======subscribe_fail_1st=======
=======publish_part2=======
subscribe
unko
1
message
unko
testmessagepart2
1
=======publish_part3=======
subscribe
nohoge
1
message
unko
testmessagepart3
1
=======publish_part4=======
message
unko
testmessagepart4
1
=======publish_part5=======
message
unko
testmessagepart5
1
=======subscribe_success_final=======
=======pubsub_channel_lists=======
nohoge
unko
=======pubsub_nums_channel_lists=======
subscribe
unko
1
unko
2
ERR unknown command `LATEST-MESSAGE`, with args beginning with: `unko`, 

nohoge
1
=======final_redis_ping=======
PONG
=======unsubscribe=======
unsubscribe
unko
0
```

#### キャッシュ機能

#### 構造

### あとがき

### 参考

* https://symfoware.blog.fc2.com/blog-entry-1366.html