0Pricing
Redis Caching & Messaging (Pub/Sub, Streams) · 강의

RedisJSON 및 RedisGraph 기초

Redis에서 JSON 문서를 저장하고 조회하는 방법과 그래프 데이터베이스 기능을 활용하는 방법을 살펴봅니다.

RedisJSON 및 RedisGraph 기초은(는) CoddyKit의 무료 Redis Caching & Messaging (Pub/Sub, Streams) 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Redis Caching & Messaging (Pub/Sub, Streams) 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Redis Caching & Messaging (Pub/Sub, Streams) 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Unlock New Data Types

Redis is incredibly versatile, but sometimes you need more specialized data handling. That's where Redis Modules come in!

These modules extend Redis's core functionality, allowing it to act as a document database, a graph database, and much more.

Introducing RedisJSON

RedisJSON is a module that lets you store, update, and retrieve JSON documents directly within Redis. This is great for managing semi-structured data like user profiles, product catalogs, or configuration settings.

  • Native JSON support: Store complex JSON objects.
  • Atomic operations: Update parts of a JSON document efficiently.
  • Powerful querying: Retrieve data using JSONPath expressions.

Storing JSON with JSON.SET

To store a JSON document, we use the JSON.SET command. You provide a key, a path (usually $ for the root), and the JSON string.

Try adding a simple user profile:

JSON.SET user:profile:1 $ '{"name": "Emma", "age": 28, "city": "London"}'

Retrieving JSON with JSON.GET

The JSON.GET command retrieves your JSON. You can get the entire document or specify a JSONPath to fetch only specific fields.

Let's get the full profile and then just Emma's name:

JSON.GET user:profile:1
JSON.GET user:profile:1 $.name

Updating JSON Fields

One of RedisJSON's strengths is updating specific parts of a document without fetching and rewriting the whole thing. Use JSON.SET with a precise path.

Update Emma's age and add a new hobby:

JSON.SET user:profile:1 $.age 29
JSON.SET user:profile:1 $.hobbies '["reading", "hiking"]'
JSON.GET user:profile:1

Introducing RedisGraph

RedisGraph is another powerful module that turns Redis into a graph database. Graph databases are excellent for modeling relationships between data, like social networks, recommendation engines, or fraud detection.

Instead of tables, you work with nodes (entities) and edges (relationships).

Graph Concepts

In RedisGraph, you'll use Cypher, a declarative graph query language, to interact with your data.

  • Nodes: Represent entities (e.g., Person, Product).
  • Labels: Categorize nodes (e.g., :Person).
  • Properties: Attributes of nodes/edges (e.g., name: 'Bob').
  • Edges: Represent relationships (e.g., -[:FRIENDS_WITH]->).

Creating Graph Data

The GRAPH.QUERY command lets you execute Cypher queries. Let's create a simple social graph with two people and a 'FRIENDS_WITH' relationship.

Notice the graph name 'social' is used to identify our graph.

GRAPH.QUERY social "CREATE (:Person {name: 'Liam'})-[:FRIENDS_WITH]->(:Person {name: 'Olivia'})"

Querying Graph Relationships

You can query the graph to find patterns and relationships. The MATCH clause finds the pattern, and RETURN specifies what data to retrieve.

Find who Liam is friends with:

GRAPH.QUERY social "MATCH (p:Person {name: 'Liam'})-[:FRIENDS_WITH]->(f:Person) RETURN p.name, f.name"

RedisJSON Path Challenge

You have a RedisJSON document stored under the key product:details:123. The document looks like this:

{
  "name": "Wireless Earbuds",
  "specs": {
    "color": "Black",
    "battery_life": "8 hours",
    "features": ["Noise Cancelling", "Waterproof"]
  }
}

Which command correctly retrieves the 'Noise Cancelling' feature?

Recap: JSON & Graphs

You've explored how RedisJSON enables efficient storage and manipulation of JSON documents using commands like JSON.SET and JSON.GET with JSONPath.

You also learned about RedisGraph, a powerful module for building and querying graph structures using Cypher, perfect for modeling relationships between data.

These modules significantly expand Redis's capabilities, letting it tackle a broader range of data modeling challenges!

자주 묻는 질문

“RedisJSON 및 RedisGraph 기초” 강의는 무료인가요?

네 — “RedisJSON 및 RedisGraph 기초” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Redis Caching & Messaging (Pub/Sub, Streams) 강의 전체를 잠금 해제할 수 있습니다. Redis Caching & Messaging (Pub/Sub, Streams) 강의에는 총 4개의 강의가 포함되어 있습니다.

“RedisJSON 및 RedisGraph 기초”에서 뭘 배우나요?

Redis에서 JSON 문서를 저장하고 조회하는 방법과 그래프 데이터베이스 기능을 활용하는 방법을 살펴봅니다. 브라우저에서 직접 실행하는 실습 코드로 Redis Caching & Messaging (Pub/Sub, Streams)을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Redis Caching & Messaging (Pub/Sub, Streams)을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Redis Caching & Messaging (Pub/Sub, Streams)은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.

“RedisJSON 및 RedisGraph 기초” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Redis Caching & Messaging (Pub/Sub, Streams) 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Redis Caching & Messaging (Pub/Sub, Streams) 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Redis 모듈 개요
  2. 전문 검색을 위한 RediSearch
  3. RedisJSON 및 RedisGraph 기초
  4. RedisTimeSeries로 시계열 데이터 다루기
← Redis Caching & Messaging (Pub/Sub, Streams)(으)로 돌아가기