# Redis 사용 샘플

**URL:** <https://ask.selectfromuser.com/t/redis/65>\
**Category:** 자유게시판\
**Tags:** redis, responsefn\
**Created:** [8월 28, 2023, 8:02오전 UTC](https://ask.selectfromuser.com/t/redis/65 "2023-08-28T08:02:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hbkim](https://yyz2.discourse-cdn.com/flex032/user_avatar/ask.selectfromuser.com/hbkim/32/23_2.png) [@hbkim](https://ask.selectfromuser.com/u/hbkim)\
**Post date:** [8월 28, 2023, 8:02오전 UTC](https://ask.selectfromuser.com/t/redis/65/1 "2023-08-28T08:02:10Z")

</div>

셀렉트 편집 페이지에서 Redis 사용 시  
아래와 같이 Redis의 Command를 이용하실 수 있습니다.

관련하여 궁금하신 점이 있다면 자유롭게 문의해주세요!

```yaml
pages:
- path: test-redis
  blocks:
  - type: left
    blocks:
    - type: query
      sqlType: select
      resource: redis-cloud
      commands:
        # - PIPELINE
        - INCR orders:view
        - GET {{name}}
      params:
        - key: name
          value: orders
          help: 해당 키를 조회합니다.
    - type: query
      sqlType: select
      resource: redis-cloud
      name: >
        orders:count와 orders.view를 조회

      # 트랜잭션으로 동시에 가져옴 (하나로 실패하면 실패)
      commands: 
        - MULTI
        - GET orders:count
        - GET orders:view
        - EXEC
      # 호출 결과 response를 다루는 셀렉트 기능
      responseFn: | 
        rows[0].name = 'orders:count'
        rows[1].name = 'orders:view'
        
  - type: right
    blocks:
    - type: query
      sqlType: insert
      resource: redis-cloud
      commands: SET orders "HEY"
      reloadAfterSubmit: true
      name: orders를 HEY 입력
    - type: query
      sqlType: insert
      resource: redis
      name: orders에 값 추가
      commands:
        - SET orders "{{name}}"
        - INCR orders:count
      params:
        - key: name
      reloadAfterSubmit: true
```
