mirror of https://mirror.osredm.com/root/redis.git
Merge branch 'unstable' into fix-keysizes-spop-setrange
This commit is contained in:
commit
a4d68ca819
|
@ -606,6 +606,50 @@ jobs:
|
|||
if: true && !contains(github.event.inputs.skiptests, 'unittest')
|
||||
run: ./src/redis-server test all
|
||||
|
||||
test-sanitizer-memory:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' || (github.event_name != 'workflow_dispatch' && github.repository == 'redis/redis')) &&
|
||||
!contains(github.event.inputs.skipjobs, 'sanitizer')
|
||||
timeout-minutes: 14400
|
||||
env:
|
||||
CC: clang # MSan work only with clang
|
||||
steps:
|
||||
- name: prep
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
run: |
|
||||
echo "GITHUB_REPOSITORY=${{github.event.inputs.use_repo}}" >> $GITHUB_ENV
|
||||
echo "GITHUB_HEAD_REF=${{github.event.inputs.use_git_ref}}" >> $GITHUB_ENV
|
||||
echo "skipjobs: ${{github.event.inputs.skipjobs}}"
|
||||
echo "skiptests: ${{github.event.inputs.skiptests}}"
|
||||
echo "test_args: ${{github.event.inputs.test_args}}"
|
||||
echo "cluster_test_args: ${{github.event.inputs.cluster_test_args}}"
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ env.GITHUB_REPOSITORY }}
|
||||
ref: ${{ env.GITHUB_HEAD_REF }}
|
||||
- name: make
|
||||
run: make SANITIZER=memory REDIS_CFLAGS='-DREDIS_TEST -Werror -DDEBUG_ASSERTIONS'
|
||||
- name: testprep
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install tcl8.6 tclx -y
|
||||
- name: test
|
||||
if: true && !contains(github.event.inputs.skiptests, 'redis')
|
||||
run: ./runtest --accurate --verbose --dump-logs ${{github.event.inputs.test_args}}
|
||||
- name: module api test
|
||||
if: true && !contains(github.event.inputs.skiptests, 'modules')
|
||||
run: SANITIZER=memory CFLAGS='-Werror' ./runtest-moduleapi --verbose --dump-logs ${{github.event.inputs.test_args}}
|
||||
- name: sentinel tests
|
||||
if: true && !contains(github.event.inputs.skiptests, 'sentinel')
|
||||
run: ./runtest-sentinel ${{github.event.inputs.cluster_test_args}}
|
||||
- name: cluster tests
|
||||
if: true && !contains(github.event.inputs.skiptests, 'cluster')
|
||||
run: ./runtest-cluster ${{github.event.inputs.cluster_test_args}}
|
||||
- name: unittest
|
||||
if: true && !contains(github.event.inputs.skiptests, 'unittest')
|
||||
run: ./src/redis-server test all
|
||||
|
||||
test-sanitizer-undefined:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
|
|
425
README.md
425
README.md
|
@ -1,32 +1,85 @@
|
|||
[](https://codecov.io/github/redis/redis)
|
||||
|
||||
This README is just a fast *quick start* document. You can find more detailed documentation at [redis.io](https://redis.io).
|
||||
This document serves as both a quick start guide to Redis and a detailed resource for building it from source.
|
||||
|
||||
### What is Redis?
|
||||
- New to Redis? Start with [What is Redis](#what-is-redis) and [Getting Started](#getting-started)
|
||||
- Ready to build from source? Jump to [Build Redis from Source](#build-redis-from-source)
|
||||
- Want to contribute? See the [Code contributions](#code-contributions) section
|
||||
and [CONTRIBUTING.md](./CONTRIBUTING.md)
|
||||
- Looking for detailed documentation? Navigate to [redis.io/docs](https://redis.io/docs/)
|
||||
|
||||
## Table of contents
|
||||
|
||||
- [What is Redis?](#what-is-redis)
|
||||
- [Key use cases](#key-use-cases)
|
||||
- [Why choose Redis?](#why-choose-redis)
|
||||
- [What is Redis Open Source?](#what-is-redis-open-source)
|
||||
- [Getting started](#getting-started)
|
||||
- [Redis starter projects](#redis-starter-projects)
|
||||
- [Using Redis with client libraries](#using-redis-with-client-libraries)
|
||||
- [Using Redis with redis-cli](#using-redis-with-redis-cli)
|
||||
- [Using Redis with Redis Insight](#using-redis-with-redis-insight)
|
||||
- [Redis data types, processing engines, and capabilities](#redis-data-types-processing-engines-and-capabilities)
|
||||
- [Community](#community)
|
||||
- [Build Redis from source](#build-redis-from-source)
|
||||
- [Build and run Redis with all data structures - Ubuntu 20.04 (Focal)](#build-and-run-redis-with-all-data-structures---ubuntu-2004-focal)
|
||||
- [Build and run Redis with all data structures - Ubuntu 22.04 (Jammy) / 24.04 (Noble)](#build-and-run-redis-with-all-data-structures---ubuntu-2204-jammy--2404-noble)
|
||||
- [Build and run Redis with all data structures - Debian 11 (Bullseye) / 12 (Bookworm)](#build-and-run-redis-with-all-data-structures---debian-11-bullseye--12-bookworm)
|
||||
- [Build and run Redis with all data structures - AlmaLinux 8.10 / Rocky Linux 8.10](#build-and-run-redis-with-all-data-structures---almalinux-810--rocky-linux-810)
|
||||
- [Build and run Redis with all data structures - AlmaLinux 9.5 / Rocky Linux 9.5](#build-and-run-redis-with-all-data-structures---almalinux-95--rocky-linux-95)
|
||||
- [Build and run Redis with all data structures - macOS 13 (Ventura) and macOS 14 (Sonoma)](#build-and-run-redis-with-all-data-structures---macos-13-ventura-and-macos-14-sonoma)
|
||||
- [Build and run Redis with all data structures - macOS 15 (Sequoia)](#build-and-run-redis-with-all-data-structures---macos-15-sequoia)
|
||||
- [Building Redis - flags and general notes](#building-redis---flags-and-general-notes)
|
||||
- [Fixing build problems with dependencies or cached build options](#fixing-build-problems-with-dependencies-or-cached-build-options)
|
||||
- [Fixing problems building 32 bit binaries](#fixing-problems-building-32-bit-binaries)
|
||||
- [Allocator](#allocator)
|
||||
- [Monotonic clock](#monotonic-clock)
|
||||
- [Verbose build](#verbose-build)
|
||||
- [Running Redis with TLS](#running-redis-with-tls)
|
||||
- [Code contributions](#code-contributions)
|
||||
- [Redis Trademarks](#redis-trademarks)
|
||||
|
||||
## What is Redis?
|
||||
|
||||
For developers, who are building real-time data-driven applications, Redis is the preferred, fastest, and most feature-rich cache, data structure server, and document and vector query engine.
|
||||
|
||||
Redis covers a wide range of use cases across a wide range of industries and projects, serving as
|
||||
- **A cache**, supporting multiple key eviction policies, key expiration, and hash-field expiration
|
||||
- **A distributed session store**, supporting multiple session data modeling options (string, JSON, hash).
|
||||
- **A data structure server**: low-level data structures (string, JSON, list, hash, set, sorted set, bitmap, bitfield, and more - see full list below) with high-level semantics (counter, stack, queue, priority queue, rate limiter, leaderboard, ...), and with transactions and scripting support.
|
||||
- **A NoSQL data store**: key-value, document, and time series.
|
||||
- **A secondary index and a search and query engine**: with Redis Query Engine users can define indexes for hash and JSON documents, and use a rich query language for vector search, full-text search, geospatial queries, ranking, and aggregations.
|
||||
- **A distributed event store, stream-processing platform, and message broker**: queue (list), priority queue (sorted set), event deduplication (set), streams, and pub/sub, with probabilistic stream processing capabilities.
|
||||
- **A vector store**, integrated with GenAI applications and ecosystems (e.g., LangGraph, mem0), providing short-term memory (checkpointers), long-term memory (store), LLM response caching (LLM semantic cache), and context retrieval (RAG applications).
|
||||
- **Real time analytics**, including personalization, recommendations, fraud and anomaly detection, and risk assessment.
|
||||
### Key use cases
|
||||
|
||||
Redis excels in various applications, including:
|
||||
|
||||
Redis can be relied upon (it is robust and has a well-defined behavior), it comes with a long-term commitment (we keep maintaining Redis, avoid introducing breaking changes, and keep it innovative and competitive). Redis is fast and has a low memory footprint (with the right tradeoffs), easy to understand, learn, and use, and easy to adopt across a wide range of development environments and languages.
|
||||
- **Caching:** Supports multiple eviction policies, key expiration, and hash-field expiration.
|
||||
- **Distributed Session Store:** Offers flexible session data modeling (string, JSON, hash).
|
||||
- **Data Structure Server:** Provides low-level data structures (strings, lists, sets, hashes, sorted sets, JSON, etc.) with high-level semantics (counters, queues, leaderboards, rate limiters) and supports transactions & scripting.
|
||||
- **NoSQL Data Store:** Key-value, document, and time series data storage.
|
||||
- **Search and Query Engine:** Indexing for hash/JSON documents, supporting vector search, full-text search, geospatial queries, ranking, and aggregations via Redis Query Engine.
|
||||
- **Event Store & Message Broker:** Implements queues (lists), priority queues (sorted sets), event deduplication (sets), streams, and pub/sub with probabilistic stream processing capabilities.
|
||||
- **Vector Store for GenAI:** Integrates with AI applications (e.g. LangGraph, mem0) for short-term memory, long-term memory, LLM response caching (semantic caching), and retrieval augmented generation (RAG).
|
||||
- **Real-Time Analytics:** Powers personalization, recommendations, fraud detection, and risk assessment.
|
||||
|
||||
If you want to know more, here is a list of starting points:
|
||||
## Why choose Redis?
|
||||
|
||||
- Introduction to Redis data types - https://redis.io/docs/latest/develop/data-types/
|
||||
- The full list of Redis commands - https://redis.io/commands
|
||||
- Redis for AI - https://redis.io/docs/latest/develop/ai/
|
||||
- and much more - https://redis.io/documentation
|
||||
Redis is a popular choice for developers worldwide due to its combination of speed, flexibility, and rich feature set. Here's why people choose Redis for:
|
||||
|
||||
### What is Redis Open Source?
|
||||
- **Performance:** Because Redis keeps data primarily in memory and uses efficient data structures, it achieves extremely low latency (often sub-millisecond) for both read and write operations. This makes it ideal for applications demanding real-time responsiveness.
|
||||
- **Flexibility:** Redis isn't just a key-value store, it provides native support for a wide range of data structures and capabilities listed in [What is Redis?](#what-is-redis)
|
||||
- **Extensibility:** Redis is not limited to the built-in data structures, it has a [modules API](https://redis.io/docs/latest/develop/reference/modules/) that makes it possible to extend Redis functionality and rapidly implement new Redis commands
|
||||
- **Simplicity:** Redis has a simple, text-based protocol and [well-documented command set](https://redis.io/docs/latest/commands/)
|
||||
- **Ubiquity:** Redis is battle tested in production workloads at a massive scale. There is a good chance you indirectly interact with Redis several times daily
|
||||
- **Versatility**: Redis is the de facto standard for use cases such as:
|
||||
- **Caching:** quickly access frequently used data without needing to query your primary database
|
||||
- **Session management:** read and write user session data without hurting user experience or slowing down every API call
|
||||
- **Querying, sorting, and analytics:** perform deduplication, full text search, and secondary indexing on in-memory data as fast as possible
|
||||
- **Messaging and interservice communication:** job queues, message brokering, pub/sub, and streams for communicating between services
|
||||
- **Vector operations:** Long-term and short-term LLM memory, RAG content retrieval, semantic caching, semantic routing, and vector similarity search
|
||||
|
||||
In summary, Redis provides a powerful, fast, and flexible toolkit for solving a wide variety of data management challenges. If you want to know more, here is a list of starting points:
|
||||
|
||||
- [**Introduction to Redis data types**](https://redis.io/docs/latest/develop/data-types/)
|
||||
- [**The full list of Redis commands**](https://redis.io/commands/)
|
||||
- [**Redis for AI**](https://redis.io/docs/latest/develop/ai/)
|
||||
- [**Redis documentation**](https://redis.io/documentation/)
|
||||
|
||||
## What is Redis Open Source?
|
||||
|
||||
Redis Community Edition (Redis CE) was renamed Redis Open Source with the v8.0 release.
|
||||
|
||||
|
@ -35,29 +88,61 @@ and [Redis Cloud](https://redis.io/cloud/), a fully managed service integrated w
|
|||
|
||||
Read more about the differences between Redis Open Source and Redis [here](https://redis.io/technology/advantages/).
|
||||
|
||||
### Redis Open Source - binary distributions
|
||||
## Getting started
|
||||
|
||||
The fastest way to deploy Redis is using one the binary distributions:
|
||||
If you want to get up and running with Redis quickly without needing to build from source, use one of the following methods:
|
||||
|
||||
- Alpine and Debian Docker images - https://hub.docker.com/_/redis
|
||||
- Install using snap - see https://github.com/redis/redis-snap
|
||||
- Install using brew - see https://github.com/redis/homebrew-redis
|
||||
- Install using RPM - see https://github.com/redis/redis-rpm
|
||||
- Install using Debian APT - see https://github.com/redis/redis-debian
|
||||
- [**Redis Cloud**](https://cloud.redis.io/)
|
||||
- [**Official Redis Docker images (Alpine/Debian)**](https://hub.docker.com/_/redis)
|
||||
```sh
|
||||
docker run -d -p 6379:6379 redis:latest
|
||||
```
|
||||
- **Redis binary distributions**
|
||||
- [**Snap**](https://github.com/redis/redis-snap)
|
||||
- [**Homebrew**](https://github.com/redis/homebrew-redis)
|
||||
- [**RPM**](https://github.com/redis/redis-rpm)
|
||||
- [**Debian**](https://github.com/redis/redis-debian)
|
||||
- [**Redis quick start guides**](https://redis.io/docs/latest/develop/get-started/)
|
||||
|
||||
If you prefer to build Redis from source - see instructions below.
|
||||
If you prefer to [build Redis from source](#build-redis-from-source) - see instructions below.
|
||||
|
||||
### Redis starter projects
|
||||
|
||||
To get started as quickly as possible in your language of choice, use one of the following starter projects:
|
||||
|
||||
- [**Python (redis-py)**](https://github.com/redis-developer/redis-starter-python)
|
||||
- [**C#/.NET (NRedisStack/StackExchange.Redis)**](https://github.com/redis-developer/redis-starter-csharp)
|
||||
- [**Go (go-redis)**](https://github.com/redis-developer/redis-starter-go)
|
||||
- [**JavaScript (node-redis)**](https://github.com/redis-developer/redis-starter-js)
|
||||
- [**Java/Spring (Jedis)**](https://github.com/redis-developer/redis-starter-java)
|
||||
|
||||
### Using Redis with client libraries
|
||||
|
||||
To connect your application to Redis, you will need a client library. Redis has documented client libraries in most popular languages, with community-supported client libraries in additional languages.
|
||||
|
||||
- [**Python (redis-py)**](https://redis.io/docs/latest/develop/clients/redis-py/)
|
||||
- [**Python (RedisVL)**](https://redis.io/docs/latest/integrate/redisvl/)
|
||||
- [**C#/.NET (NRedisStack/StackExchange.Redis)**](https://redis.io/docs/latest/develop/clients/dotnet/)
|
||||
- [**JavaScript (node-redis)**](https://redis.io/docs/latest/develop/clients/nodejs/)
|
||||
- [**Java (Jedis)**](https://redis.io/docs/latest/develop/clients/jedis/)
|
||||
- [**Java (Lettuce)**](https://redis.io/docs/latest/develop/clients/lettuce/)
|
||||
- [**Go (go-redis)**](https://redis.io/docs/latest/develop/clients/go/)
|
||||
- [**PHP (Predis)**](https://redis.io/docs/latest/develop/clients/php/)
|
||||
- [**C (hiredis)**](https://redis.io/docs/latest/develop/clients/hiredis/)
|
||||
- [**Full list of client libraries**](https://redis.io/docs/latest/develop/clients/)
|
||||
|
||||
### Using Redis with redis-cli
|
||||
|
||||
`redis-cli` is Redis' command line interface. It is available as part of all the binary distributions and when you build Redis from source.
|
||||
|
||||
See https://redis.io/docs/latest/develop/tools/cli/
|
||||
[`redis-cli`](https://redis.io/docs/latest/develop/tools/cli/) is Redis' command line interface. It is available as part of all the binary distributions and when you build Redis from source.
|
||||
|
||||
You can start a redis-server instance, and then, in another terminal try the following:
|
||||
|
||||
```sh
|
||||
cd src
|
||||
./redis-cli
|
||||
```
|
||||
% cd src
|
||||
% ./redis-cli
|
||||
|
||||
```text
|
||||
redis> ping
|
||||
PONG
|
||||
redis> set foo bar
|
||||
|
@ -72,119 +157,61 @@ redis>
|
|||
```
|
||||
|
||||
### Using Redis with Redis Insight
|
||||
For a more visual and user-friendly experience, use Redis Insight - a tool that lets you explore data, design, develop, and optimize your applications while also serving as a platform for Redis education and onboarding. Redis Insight integrates Redis Copilot, a natural language AI assistant that improves the experience when working with data and commands.
|
||||
See https://redis.io/docs/latest/develop/tools/insight/ and https://github.com/RedisInsight/RedisInsight.
|
||||
|
||||
For a more visual and user-friendly experience, use [Redis Insight](https://redis.io/docs/latest/develop/tools/insight/) - a tool that lets you explore data, design, develop, and optimize your applications while also serving as a platform for Redis education and onboarding. Redis Insight integrates [Redis Copilot](https://redis.io/chat), a natural language AI assistant that improves the experience when working with data and commands.
|
||||
|
||||
### Using Redis with client libraries
|
||||
- [**Redis Insight documentation**](https://redis.io/docs/latest/develop/tools/insight/)
|
||||
- [**Redis Insight GitHub repository**](https://github.com/RedisInsight/RedisInsight)
|
||||
|
||||
To connect your application to Redis, you will need a client library. The list of client libraries is available in https://redis.io/docs/latest/develop/clients/.
|
||||
|
||||
### Redis Data types, processing engines, and capabilities
|
||||
## Redis data types, processing engines, and capabilities
|
||||
|
||||
Redis provides a variety of data types, processing engines, and capabilities to support a wide range of use cases:
|
||||
|
||||
1. **String**
|
||||
- Strings store sequences of bytes, including text, serialized objects, and binary arrays. As such, strings are the simplest type of value you can associate with a Redis key.
|
||||
- [Documentation: Strings](https://redis.io/docs/latest/develop/data-types/strings)
|
||||
**Important:** Features marked with an asterisk (\*) require Redis to be compiled with the `BUILD_WITH_MODULES=yes` flag when [building Redis from source](#build-redis-from-source)
|
||||
|
||||
1. **JSON** (*)
|
||||
- The JSON data type provides JavaScript Object Notation (JSON) support for Redis. It lets you store, retrieve, and update JSON documents. A JSON document can be queried and manipulated using JSONPath expressions. JSON also works seamlessly with the Redis Query Engine to let you index and query JSON documents.
|
||||
- [Documentation: JSON quick start](https://redis.io/docs/latest/develop/data-types/json/#use-redisjson)
|
||||
- [**String:**](https://redis.io/docs/latest/develop/data-types/strings) Sequences of bytes, including text, serialized objects, and binary arrays used for caching, counters, and bitwise operations.
|
||||
- [**JSON:**](https://redis.io/docs/latest/develop/data-types/json/) Nested JSON documents that are indexed and searchable using JSONPath expressions and with [Redis Query Engine](https://redis.io/docs/latest/develop/interact/search-and-query/)
|
||||
- [**Hash:**](https://redis.io/docs/latest/develop/data-types/hashes/) Field-value maps used to represent basic objects and store groupings of key-value pairs with support for [hash field expiration (TTL)](https://redis.io/docs/latest/develop/data-types/hashes/#field-expiration)
|
||||
- [**Redis Query Engine:**](https://redis.io/docs/latest/develop/interact/search-and-query/) Use Redis as a document database, a vector database, a secondary index, and a search engine. Define indexes for hash and JSON documents and then use a rich query language for vector search, full-text search, geospatial queries, and aggregations.
|
||||
- [**List:**](https://redis.io/docs/latest/develop/data-types/lists/) Linked lists of string values used as stacks, queues, and for queue management.
|
||||
- [**Set:**](https://redis.io/docs/latest/develop/data-types/sets/) Unordered collection of unique strings used for tracking unique items, relations, and common set operations (intersections, unions, differences).
|
||||
- [**Sorted set:**](https://redis.io/docs/latest/develop/data-types/sorted-sets/) Collection of unique strings ordered by an associated score used for leaderboards and rate limiters.
|
||||
- [**Vector set (beta):**](https://redis.io/docs/latest/develop/data-types/vector-sets/) Collection of vector embeddings used for semantic similarity search, semantic caching, semantic routing, and Retrieval Augmented Generation (RAG).
|
||||
- [**Geospatial indexes:**](https://redis.io/docs/latest/develop/data-types/geospatial/) Coordinates used for finding nearby points within a given radius or bounding box.
|
||||
- [**Bitmap:**](https://redis.io/docs/latest/develop/data-types/bitmaps/) A set of bit-oriented operations defined on the string type used for efficient set representations and object permissions.
|
||||
- [**Bitfield:**](https://redis.io/docs/latest/develop/data-types/bitfields/) Binary-encoded strings that let you set, increment, and get integer values of arbitrary bit length used for limited-range counters, numeric values, and multi-level object permissions such as role-based access control (RBAC)
|
||||
- [**Hyperloglog:**](https://redis.io/docs/latest/develop/data-types/probabilistic/hyperloglogs/) A probabilistic data structure for approximating the cardinality of a set used for analytics such as counting unique visits, form fills, etc.
|
||||
- \*[**Bloom filter:**](https://redis.io/docs/latest/develop/data-types/probabilistic/bloom-filter/) A probabilistic data structure to check if a given value is present in a set. Used for fraud detection, ad placement, and unique column (i.e. username/email/slug) checks.
|
||||
- \*[**Cuckoo filter:**](https://redis.io/docs/latest/develop/data-types/probabilistic/cuckoo-filter/) A probabilistic data structure for checking if a given value is present in a set while also allowing limited counting and deletions used in targeted advertising and coupon code validation.
|
||||
- \*[**t-digest:**](https://redis.io/docs/latest/develop/data-types/probabilistic/t-digest/) A probabilistic data structure used for estimating the percentile of a large dataset without having to store and order all the data points. Used for hardware/software monitoring, online gaming, network traffic monitoring, and predictive maintenance.
|
||||
- \*[**Top-k:**](https://redis.io/docs/latest/develop/data-types/probabilistic/top-k/) A probabilistic data structure for finding the most frequent values in a data stream used for trend discovery.
|
||||
- \*[**Count-min sketch:**](https://redis.io/docs/latest/develop/data-types/probabilistic/count-min-sketch/) A probabilistic data structure for estimating how many times a given value appears in a data stream used for sales volume calculations.
|
||||
- [**Time series:**](https://redis.io/docs/latest/develop/data-types/timeseries/) Data points indexed in time order used for monitoring sensor data, asset
|
||||
tracking, and predictive analytics
|
||||
- [**Pub/sub**:](https://redis.io/docs/latest/develop/interact/pubsub/) A lightweight messaging capability. Publishers send messages to a channel, and subscribers receive messages from that channel.
|
||||
- [**Stream**:](https://redis.io/docs/latest/develop/data-types/streams/) An append-only log with random access capabilities and complex consumption strategies such as consumer groups. Used for event sourcing, sensor monitoring, and notifications.
|
||||
- [**Transaction:**](https://redis.io/docs/latest/develop/interact/transactions/) Allows the execution of a group of commands in a single step. A request sent by another client will never be served in the middle of the execution of a transaction. This guarantees that the commands are executed as a single isolated operation.
|
||||
- [**Programmability:**](https://redis.io/docs/latest/develop/interact/programmability/eval-intro/) Upload and execute Lua scripts on the server. Scripts can employ programmatic control structures and use most of the commands while executing to access the database. Because scripts are executed on the server, reading and writing data from scripts is very efficient.
|
||||
|
||||
1. **Hash**
|
||||
- A hash is a collection of fields, each field is a name-value string pair. You can use hashes to represent flat objects and to store groupings of counters, among other things. Expiration time or a time-to-live can be set for each hash field.
|
||||
- [Documentation: Hashes](https://redis.io/docs/latest/develop/data-types/hashes)
|
||||
## Community
|
||||
|
||||
1. **Redis Query Engine** (*)
|
||||
- The Redis Query Engine allows you to use Redis as a document database, a vector database, a secondary index, and a search engine. With Redis Query Engine, users can define indexes for hash and JSON documents, and use a rich query language for vector search, full-text search, geospatial queries, and aggregations.
|
||||
- [Documentation: Redis Query Engine](https://redis.io/docs/latest/develop/interact/search-and-query/)
|
||||
[**Redis Community Resources**](https://redis.io/community/)
|
||||
|
||||
1. **List**
|
||||
- A list is a list of strings, sorted by insertion order. They are great for stacks, queues, and for queue management and worker systems.
|
||||
- [Documentation: Lists](https://redis.io/docs/latest/develop/data-types/lists)
|
||||
## Build Redis from source
|
||||
|
||||
1. **Set**
|
||||
- A set is an unordered collection of unique strings (members). Sets can be used to track unique items (e.g., track all unique IP addresses accessing a given blog post), represent relations (e.g., the set of all users with a given role). Redis also supports common set operations such as intersection, unions, and differences.
|
||||
- [Documentation: Sets](https://redis.io/docs/latest/develop/data-types/sets)
|
||||
|
||||
1. **Sorted Set**
|
||||
- A sorted set is similar to a set, but each member is associated with a score. When more than one member has the same score, the members are ordered lexicographically. Some use cases for sorted sets include leaderboards and sliding-window rate limiters.
|
||||
- [Documentation: Sorted Sets](https://redis.io/docs/latest/develop/data-types/sorted-sets)
|
||||
|
||||
1. **Vector Set** (beta)
|
||||
- Vector set is a data type similar to a sorted set, but instead of a score, each member is associated with a vector embedding. You can add items to a vector set, and then retrieve the members that are the most similar to a specified vector embedding, or to the vector embedding of an existing member.
|
||||
- [Documentation: Vector sets](https://redis.io/docs/latest/develop/data-types/vector-sets)
|
||||
|
||||
1. **Geospatial Index**
|
||||
- Geospatial indexes let you store coordinates and search for them. This data structure is useful for finding nearby points within a given radius or bounding box.
|
||||
- [Documentation: Geo](https://redis.io/docs/latest/develop/data-types/geospatial/)
|
||||
|
||||
1. **Bitmap**
|
||||
- Bitmaps provide bit-oriented operations on a bit vector. You can get bits, set bits, and perform bitwise operations between bitmaps. Bitmaps are often used for efficient management of memberships or permissions, where each bit represents a particular member.
|
||||
- [Documentation: Bitmap](https://redis.io/docs/latest/develop/data-types/bitmaps/)
|
||||
|
||||
1. **Bitfield**
|
||||
- Bitfields let you set, increment, and get integer values of arbitrary bit length - from unsigned 1-bit integers to signed 63-bit integers. Bitfields are often used for efficient management of arrays of limited-range counters or numerical values.
|
||||
- [Documentation: Bitfield](https://redis.io/docs/latest/develop/data-types/bitfields/)
|
||||
|
||||
1. **HyperLogLog**
|
||||
- HyperLogLog is a probabilistic data structure used for approximating the cardinality of a stream (i.e., the number of unique elements).
|
||||
- [Documentation: HyperLogLog](https://redis.io/docs/latest/develop/data-types/hyperloglogs)
|
||||
|
||||
1. **Bloom filter** (*)
|
||||
- Bloom filter is a probabilistic data structure used for checking if a given value is present in a stream.
|
||||
- [Documentation: Bloom filter](https://redis.io/docs/latest/develop/data-types/probabilistic/bloom-filter/)
|
||||
|
||||
1. **Cuckoo filter** (*)
|
||||
- Cuckoo filter, just like Bloom filter, is a probabilistic data structure for checking if a given value is present in a stream, while also allowing limited counting and deletions.
|
||||
- [Documentation: Cuckoo filter](https://redis.io/docs/latest/develop/data-types/probabilistic/cuckoo-filter/)
|
||||
|
||||
1. **Top-k** (*)
|
||||
- Top-k is a probabilistic data structure used for tracking the most frequent values in a data stream.
|
||||
- [Documentation: Top-k](https://redis.io/docs/latest/develop/data-types/probabilistic/top-k/)
|
||||
|
||||
1. **Count-min sketch** (*)
|
||||
- Count-Min Sketch is a probabilistic data structure used for estimating how many times a given value appears in the data stream.
|
||||
- [Documentation: Count-min sketch](https://redis.io/docs/latest/develop/data-types/probabilistic/count-min-sketch/)
|
||||
|
||||
1. **t-digest** (*)
|
||||
- t-digest is a probabilistic data structure used for estimating which fraction / how many values in a data stream are smaller than a given value, which value is smaller than p percent of the values in a data stream, or what are the smallest/largest values in the data stream.
|
||||
- [Documentation: t-digeset](https://redis.io/docs/latest/develop/data-types/probabilistic/t-digest/)
|
||||
|
||||
1. **Time series** (*)
|
||||
- a time series allows storing and querying timetagged data points (samples).
|
||||
- [Documentation: Time series quick start](https://redis.io/docs/latest/develop/data-types/timeseries/quickstart/)
|
||||
|
||||
1. **Pub/Sub**
|
||||
- Pub/Sub (short for publish/subscribe) is a lightweight messaging capability. Publishers send messages to a channel, and subscribers receive messages from that channel.
|
||||
- [Documentation: Redis streams](https://redis.io/docs/latest/develop/interact/pubsub/)
|
||||
|
||||
1. **Stream**
|
||||
- A stream is a data structure that acts like an append-only log. Each stream entry consists of name-value string pairs, similar to a hash. Streams support multiple consumption strategies, where consumers can pop entries, consume entries by range, or listen to entries. Consumer groups allow multiple workers to retrieve different stream entries in order to scale message processing.
|
||||
- [Documentation: Redis streams](https://redis.io/docs/latest/develop/data-types/streams/)
|
||||
|
||||
1. **Transactions**
|
||||
- A transaction allows the execution of a group of commands in a single step. A request sent by another client will never be served in the middle of the execution of a transaction. This guarantees that the commands are executed as a single isolated operation.
|
||||
- [Documentation: Transactions](https://redis.io/docs/latest/develop/interact/transactions/)
|
||||
|
||||
1. **Programmability**
|
||||
- Users can upload and execute Lua scripts on the server. Scripts can employ programmatic control structures and use most of the commands while executing to access the database. Because scripts are executed on the server, reading and writing data from scripts is very efficient. Functions provide the same core functionality as scripts but are first-class software artifacts of the database. Redis manages functions as an integral part of the database and ensures their availability via data persistence and replication.
|
||||
- [Documentation: Scripting with Lua](https://redis.io/docs/latest/develop/interact/programmability/eval-intro/)
|
||||
- [Documentation: Functions](https://redis.io/docs/latest/develop/interact/programmability/functions-intro/)
|
||||
|
||||
Items marked with (*) require building with `BUILD_WITH_MODULES=yes`.
|
||||
This section refers to building Redis from source. If you want to get up and running with Redis quickly without needing to build from source see the [Getting started section](#getting-started).
|
||||
|
||||
### Build and run Redis with all data structures - Ubuntu 20.04 (Focal)
|
||||
|
||||
Tested with the following Docker images:
|
||||
|
||||
- ubuntu:20.04
|
||||
|
||||
1. Install required dependencies
|
||||
|
||||
Update your package lists and install the necessary development tools and libraries:
|
||||
|
||||
```
|
||||
```sh
|
||||
apt-get update
|
||||
apt-get install -y sudo
|
||||
sudo apt-get install -y --no-install-recommends ca-certificates wget dpkg-dev gcc g++ libc6-dev libssl-dev make git python3 python3-pip python3-venv python3-dev unzip rsync clang automake autoconf gcc-10 g++-10 libtool
|
||||
|
@ -194,7 +221,7 @@ Tested with the following Docker images:
|
|||
|
||||
Update the system's default compiler to GCC 10:
|
||||
|
||||
```
|
||||
```sh
|
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10
|
||||
```
|
||||
|
||||
|
@ -202,7 +229,7 @@ Tested with the following Docker images:
|
|||
|
||||
Install CMake using `pip3` and link it for system-wide access:
|
||||
|
||||
```
|
||||
```sh
|
||||
pip3 install cmake==3.31.6
|
||||
sudo ln -sf /usr/local/bin/cmake /usr/bin/cmake
|
||||
cmake --version
|
||||
|
@ -216,7 +243,7 @@ Tested with the following Docker images:
|
|||
|
||||
Replace `<version>` with the Redis version, for example: `8.0.0`.
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src
|
||||
wget -O redis-<version>.tar.gz https://github.com/redis/redis/archive/refs/tags/<version>.tar.gz
|
||||
```
|
||||
|
@ -225,7 +252,7 @@ Tested with the following Docker images:
|
|||
|
||||
Create a directory for the source code and extract the contents into it:
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src
|
||||
tar xvf redis-<version>.tar.gz
|
||||
rm redis-<version>.tar.gz
|
||||
|
@ -235,7 +262,7 @@ Tested with the following Docker images:
|
|||
|
||||
Set the necessary environment variables and compile Redis:
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src/redis-<version>
|
||||
export BUILD_TLS=yes BUILD_WITH_MODULES=yes INSTALL_RUST_TOOLCHAIN=yes DISABLE_WERRORS=yes
|
||||
make -j "$(nproc)" all
|
||||
|
@ -243,14 +270,15 @@ Tested with the following Docker images:
|
|||
|
||||
7. Run Redis
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src/redis-<version>
|
||||
./src/redis-server redis-full.conf
|
||||
```
|
||||
```
|
||||
|
||||
### Build and run Redis with all data structures - Ubuntu 22.04 (Jammy) / 24.04 (Noble)
|
||||
|
||||
Tested with the following Docker image:
|
||||
|
||||
- ubuntu:22.04
|
||||
- ubuntu:24.04
|
||||
|
||||
|
@ -258,7 +286,7 @@ Tested with the following Docker image:
|
|||
|
||||
Update your package lists and install the necessary development tools and libraries:
|
||||
|
||||
```
|
||||
```sh
|
||||
apt-get update
|
||||
apt-get install -y sudo
|
||||
sudo apt-get install -y --no-install-recommends ca-certificates wget dpkg-dev gcc g++ libc6-dev libssl-dev make git cmake python3 python3-pip python3-venv python3-dev unzip rsync clang automake autoconf libtool
|
||||
|
@ -270,7 +298,7 @@ Tested with the following Docker image:
|
|||
|
||||
Replace `<version>` with the Redis version, for example: `8.0.0`.
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src
|
||||
wget -O redis-<version>.tar.gz https://github.com/redis/redis/archive/refs/tags/<version>.tar.gz
|
||||
```
|
||||
|
@ -279,7 +307,7 @@ Tested with the following Docker image:
|
|||
|
||||
Create a directory for the source code and extract the contents into it:
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src
|
||||
tar xvf redis-<version>.tar.gz
|
||||
rm redis-<version>.tar.gz
|
||||
|
@ -289,7 +317,7 @@ Tested with the following Docker image:
|
|||
|
||||
Set the necessary environment variables and build Redis:
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src/redis-<version>
|
||||
export BUILD_TLS=yes BUILD_WITH_MODULES=yes INSTALL_RUST_TOOLCHAIN=yes DISABLE_WERRORS=yes
|
||||
make -j "$(nproc)" all
|
||||
|
@ -297,15 +325,15 @@ Tested with the following Docker image:
|
|||
|
||||
5. Run Redis
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src/redis-<version>
|
||||
./src/redis-server redis-full.conf
|
||||
```
|
||||
|
||||
### Build and run Redis with all data structures - Debian 11 (Bullseye) / 12 (Bookworm)
|
||||
|
||||
|
||||
Tested with the following Docker images:
|
||||
|
||||
- debian:bullseye
|
||||
- debian:bullseye-slim
|
||||
- debian:bookworm
|
||||
|
@ -315,7 +343,7 @@ Tested with the following Docker images:
|
|||
|
||||
Update your package lists and install the necessary development tools and libraries:
|
||||
|
||||
```
|
||||
```sh
|
||||
apt-get update
|
||||
apt-get install -y sudo
|
||||
sudo apt-get install -y --no-install-recommends ca-certificates wget dpkg-dev gcc g++ libc6-dev libssl-dev make git cmake python3 python3-pip python3-venv python3-dev unzip rsync clang automake autoconf libtool
|
||||
|
@ -327,7 +355,7 @@ Tested with the following Docker images:
|
|||
|
||||
Replace `<version>` with the Redis version, for example: `8.0.0`.
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src
|
||||
wget -O redis-<version>.tar.gz https://github.com/redis/redis/archive/refs/tags/<version>.tar.gz
|
||||
```
|
||||
|
@ -336,7 +364,7 @@ Tested with the following Docker images:
|
|||
|
||||
Create a directory for the source code and extract the contents into it:
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src
|
||||
tar xvf redis-<version>.tar.gz
|
||||
rm redis-<version>.tar.gz
|
||||
|
@ -346,7 +374,7 @@ Tested with the following Docker images:
|
|||
|
||||
Set the necessary environment variables and build Redis:
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src/redis-<version>
|
||||
export BUILD_TLS=yes BUILD_WITH_MODULES=yes INSTALL_RUST_TOOLCHAIN=yes DISABLE_WERRORS=yes
|
||||
make -j "$(nproc)" all
|
||||
|
@ -354,8 +382,7 @@ Tested with the following Docker images:
|
|||
|
||||
5. Run Redis
|
||||
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src/redis-<version>
|
||||
./src/redis-server redis-full.conf
|
||||
```
|
||||
|
@ -363,6 +390,7 @@ Tested with the following Docker images:
|
|||
### Build and run Redis with all data structures - AlmaLinux 8.10 / Rocky Linux 8.10
|
||||
|
||||
Tested with the following Docker images:
|
||||
|
||||
- almalinux:8.10
|
||||
- almalinux:8.10-minimal
|
||||
- rockylinux/rockylinux:8.10
|
||||
|
@ -372,19 +400,19 @@ Tested with the following Docker images:
|
|||
|
||||
For 8.10-minimal, install `sudo` and `dnf` as follows:
|
||||
|
||||
```
|
||||
```sh
|
||||
microdnf install dnf sudo -y
|
||||
```
|
||||
|
||||
For 8.10 (regular), install sudo as follows:
|
||||
|
||||
```
|
||||
```sh
|
||||
dnf install sudo -y
|
||||
```
|
||||
|
||||
Clean the package metadata, enable required repositories, and install development tools:
|
||||
|
||||
```
|
||||
```sh
|
||||
sudo dnf clean all
|
||||
sudo tee /etc/yum.repos.d/goreleaser.repo > /dev/null <<EOF
|
||||
[goreleaser]
|
||||
|
@ -403,19 +431,19 @@ Tested with the following Docker images:
|
|||
|
||||
Update your package lists and install the necessary development tools and libraries:
|
||||
|
||||
```
|
||||
```sh
|
||||
sudo dnf install -y --nobest --skip-broken pkg-config wget gcc-toolset-13-gcc gcc-toolset-13-gcc-c++ git make openssl openssl-devel python3.11 python3.11-pip python3.11-devel unzip rsync clang curl libtool automake autoconf jq systemd-devel
|
||||
```
|
||||
|
||||
Create a Python virtual environment:
|
||||
|
||||
```
|
||||
```sh
|
||||
python3.11 -m venv /opt/venv
|
||||
```
|
||||
|
||||
Enable the GCC toolset:
|
||||
|
||||
```
|
||||
```sh
|
||||
sudo cp /opt/rh/gcc-toolset-13/enable /etc/profile.d/gcc-toolset-13.sh
|
||||
echo "source /etc/profile.d/gcc-toolset-13.sh" | sudo tee -a /etc/bashrc
|
||||
```
|
||||
|
@ -424,7 +452,7 @@ Tested with the following Docker images:
|
|||
|
||||
Install CMake 3.25.1 manually:
|
||||
|
||||
```
|
||||
```sh
|
||||
CMAKE_VERSION=3.25.1
|
||||
ARCH=$(uname -m)
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
|
@ -445,7 +473,7 @@ Tested with the following Docker images:
|
|||
|
||||
Replace `<version>` with the Redis version, for example: `8.0.0`.
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src
|
||||
wget -O redis-<version>.tar.gz https://github.com/redis/redis/archive/refs/tags/<version>.tar.gz
|
||||
```
|
||||
|
@ -454,7 +482,7 @@ Tested with the following Docker images:
|
|||
|
||||
Create a directory for the source code and extract the contents into it:
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src
|
||||
tar xvf redis-<version>.tar.gz
|
||||
rm redis-<version>.tar.gz
|
||||
|
@ -464,7 +492,7 @@ Tested with the following Docker images:
|
|||
|
||||
Enable the GCC toolset, set the necessary environment variables, and build Redis:
|
||||
|
||||
```
|
||||
```sh
|
||||
source /etc/profile.d/gcc-toolset-13.sh
|
||||
cd /usr/src/redis-<version>
|
||||
export BUILD_TLS=yes BUILD_WITH_MODULES=yes INSTALL_RUST_TOOLCHAIN=yes DISABLE_WERRORS=yes
|
||||
|
@ -473,7 +501,7 @@ Tested with the following Docker images:
|
|||
|
||||
7. Run Redis
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src/redis-<version>
|
||||
./src/redis-server redis-full.conf
|
||||
```
|
||||
|
@ -481,6 +509,7 @@ Tested with the following Docker images:
|
|||
### Build and run Redis with all data structures - AlmaLinux 9.5 / Rocky Linux 9.5
|
||||
|
||||
Tested with the following Docker images:
|
||||
|
||||
- almalinux:9.5
|
||||
- almalinux:9.5-minimal
|
||||
- rockylinux/rockylinux:9.5
|
||||
|
@ -490,19 +519,19 @@ Tested with the following Docker images:
|
|||
|
||||
For 9.5-minimal, install `sudo` and `dnf` as follows:
|
||||
|
||||
```
|
||||
```sh
|
||||
microdnf install dnf sudo -y
|
||||
```
|
||||
|
||||
For 9.5 (regular), install sudo as follows:
|
||||
|
||||
```
|
||||
```sh
|
||||
dnf install sudo -y
|
||||
```
|
||||
|
||||
Clean the package metadata, enable required repositories, and install development tools:
|
||||
|
||||
```
|
||||
```sh
|
||||
sudo tee /etc/yum.repos.d/goreleaser.repo > /dev/null <<EOF
|
||||
[goreleaser]
|
||||
name=GoReleaser
|
||||
|
@ -519,19 +548,19 @@ Tested with the following Docker images:
|
|||
|
||||
Update your package lists and install the necessary development tools and libraries:
|
||||
|
||||
```
|
||||
```sh
|
||||
sudo dnf install -y --nobest --skip-broken pkg-config xz wget which gcc-toolset-13-gcc gcc-toolset-13-gcc-c++ git make openssl openssl-devel python3 python3-pip python3-devel unzip rsync clang curl libtool automake autoconf jq systemd-devel
|
||||
```
|
||||
|
||||
Create a Python virtual environment:
|
||||
|
||||
```
|
||||
```sh
|
||||
python3 -m venv /opt/venv
|
||||
```
|
||||
|
||||
Enable the GCC toolset:
|
||||
|
||||
```
|
||||
```sh
|
||||
sudo cp /opt/rh/gcc-toolset-13/enable /etc/profile.d/gcc-toolset-13.sh
|
||||
echo "source /etc/profile.d/gcc-toolset-13.sh" | sudo tee -a /etc/bashrc
|
||||
```
|
||||
|
@ -540,7 +569,7 @@ Tested with the following Docker images:
|
|||
|
||||
Install CMake 3.25.1 manually:
|
||||
|
||||
```
|
||||
```sh
|
||||
CMAKE_VERSION=3.25.1
|
||||
ARCH=$(uname -m)
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
|
@ -561,7 +590,7 @@ Tested with the following Docker images:
|
|||
|
||||
Replace `<version>` with the Redis version, for example: `8.0.0`.
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src
|
||||
wget -O redis-<version>.tar.gz https://github.com/redis/redis/archive/refs/tags/<version>.tar.gz
|
||||
```
|
||||
|
@ -570,7 +599,7 @@ Tested with the following Docker images:
|
|||
|
||||
Create a directory for the source code and extract the contents into it:
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src
|
||||
tar xvf redis-<version>.tar.gz
|
||||
rm redis-<version>.tar.gz
|
||||
|
@ -580,7 +609,7 @@ Tested with the following Docker images:
|
|||
|
||||
Enable the GCC toolset, set the necessary environment variables, and build Redis:
|
||||
|
||||
```
|
||||
```sh
|
||||
source /etc/profile.d/gcc-toolset-13.sh
|
||||
cd /usr/src/redis-<version>
|
||||
export BUILD_TLS=yes BUILD_WITH_MODULES=yes INSTALL_RUST_TOOLCHAIN=yes DISABLE_WERRORS=yes
|
||||
|
@ -589,7 +618,7 @@ Tested with the following Docker images:
|
|||
|
||||
7. Run Redis
|
||||
|
||||
```
|
||||
```sh
|
||||
cd /usr/src/redis-<version>
|
||||
./src/redis-server redis-full.conf
|
||||
```
|
||||
|
@ -602,7 +631,7 @@ Tested with the following Docker images:
|
|||
|
||||
2. Install required packages
|
||||
|
||||
```
|
||||
```sh
|
||||
export HOMEBREW_NO_AUTO_UPDATE=1
|
||||
brew update
|
||||
brew install coreutils
|
||||
|
@ -614,13 +643,13 @@ Tested with the following Docker images:
|
|||
brew install automake
|
||||
brew install libtool
|
||||
brew install wget
|
||||
```
|
||||
```
|
||||
|
||||
3. Install Rust
|
||||
|
||||
Rust is required to build the JSON package.
|
||||
|
||||
```
|
||||
```sh
|
||||
RUST_INSTALLER=rust-1.80.1-$(if [ "$(uname -m)" = "arm64" ]; then echo "aarch64"; else echo "x86_64"; fi)-apple-darwin
|
||||
wget --quiet -O ${RUST_INSTALLER}.tar.xz https://static.rust-lang.org/dist/${RUST_INSTALLER}.tar.xz
|
||||
tar -xf ${RUST_INSTALLER}.tar.xz
|
||||
|
@ -633,7 +662,7 @@ Tested with the following Docker images:
|
|||
|
||||
Replace `<version>` with the Redis version, for example: `8.0.0`.
|
||||
|
||||
```
|
||||
```sh
|
||||
cd ~/src
|
||||
wget -O redis-<version>.tar.gz https://github.com/redis/redis/archive/refs/tags/<version>.tar.gz
|
||||
```
|
||||
|
@ -642,7 +671,7 @@ Tested with the following Docker images:
|
|||
|
||||
Create a directory for the source code and extract the contents into it:
|
||||
|
||||
```
|
||||
```sh
|
||||
cd ~/src
|
||||
tar xvf redis-<version>.tar.gz
|
||||
rm redis-<version>.tar.gz
|
||||
|
@ -650,7 +679,7 @@ Tested with the following Docker images:
|
|||
|
||||
6. Build Redis
|
||||
|
||||
```
|
||||
```sh
|
||||
cd ~/src/redis-<version>
|
||||
export HOMEBREW_PREFIX="$(brew --prefix)"
|
||||
export BUILD_WITH_MODULES=yes
|
||||
|
@ -666,7 +695,7 @@ Tested with the following Docker images:
|
|||
|
||||
7. Run Redis
|
||||
|
||||
```
|
||||
```sh
|
||||
export LC_ALL=en_US.UTF-8
|
||||
export LANG=en_US.UTF-8
|
||||
build_dir/bin/redis-server redis-full.conf
|
||||
|
@ -679,62 +708,55 @@ Support and instructions will be provided at a later date.
|
|||
### Building Redis - flags and general notes
|
||||
|
||||
Redis can be compiled and used on Linux, OSX, OpenBSD, NetBSD, FreeBSD.
|
||||
We support big endian and little endian architectures, and both 32 bit and 64 bit systems.
|
||||
We support big endian and little endian architectures, and both 32 bit and 64-bit systems.
|
||||
|
||||
It may compile on Solaris derived systems (for instance SmartOS) but our support for this platform is *best effort* and Redis is not guaranteed to work as well as in Linux, OSX, and \*BSD.
|
||||
It may compile on Solaris derived systems (for instance SmartOS) but our support for this platform is _best effort_ and Redis is not guaranteed to work as well as on Linux, OSX, and \*BSD.
|
||||
|
||||
To build Redis with all the data structures (including JSON, time series, Bloom filter, cuckoo filter, count-min sketch, top-k, and t-digest) and with Redis Query Engine, make sure first that all the prerequisites are installed (see build instructions above, per operating system). You need to use the following flag in the make command:
|
||||
|
||||
|
||||
```
|
||||
```sh
|
||||
make BUILD_WITH_MODULES=yes
|
||||
```
|
||||
|
||||
|
||||
To build Redis with just the core data structures, use:
|
||||
|
||||
```
|
||||
```sh
|
||||
make
|
||||
```
|
||||
|
||||
|
||||
To build with TLS support, you need OpenSSL development libraries (e.g. libssl-dev on Debian/Ubuntu) and the following flag in the make command:
|
||||
|
||||
```
|
||||
```sh
|
||||
make BUILD_TLS=yes
|
||||
```
|
||||
|
||||
|
||||
To build with systemd support, you need systemd development libraries (such as libsystemd-dev on Debian/Ubuntu or systemd-devel on CentOS), and the following flag:
|
||||
|
||||
```
|
||||
```sh
|
||||
make USE_SYSTEMD=yes
|
||||
```
|
||||
|
||||
|
||||
To append a suffix to Redis program names, add the following flag:
|
||||
|
||||
```
|
||||
```sh
|
||||
make PROG_SUFFIX="-alt"
|
||||
```
|
||||
|
||||
|
||||
You can build a 32 bit Redis binary using:
|
||||
|
||||
```
|
||||
```sh
|
||||
make 32bit
|
||||
```
|
||||
|
||||
|
||||
After building Redis, it is a good idea to test it using:
|
||||
|
||||
```
|
||||
```sh
|
||||
make test
|
||||
```
|
||||
|
||||
If TLS is built, running the tests with TLS enabled (you will need `tcl-tls` installed):
|
||||
|
||||
```
|
||||
```sh
|
||||
./utils/gen-test-certs.sh
|
||||
./runtest --tls
|
||||
```
|
||||
|
@ -745,14 +767,13 @@ Redis has some dependencies which are included in the `deps` directory. `make` d
|
|||
|
||||
When you update the source code with `git pull` or when code inside the dependencies tree is modified in any other way, make sure to use the following command in order to really clean everything and rebuild from scratch:
|
||||
|
||||
```
|
||||
```sh
|
||||
make distclean
|
||||
```
|
||||
|
||||
|
||||
This will clean: jemalloc, lua, hiredis, linenoise and other dependencies.
|
||||
|
||||
Also if you force certain build options like 32bit target, no C compiler optimizations (for debugging purposes), and other similar build time options, those options are cached indefinitely until you issue a `make distclean`
|
||||
Also, if you force certain build options like 32bit target, no C compiler optimizations (for debugging purposes), and other similar build time options, those options are cached indefinitely until you issue a `make distclean`
|
||||
command.
|
||||
|
||||
### Fixing problems building 32 bit binaries
|
||||
|
@ -762,33 +783,33 @@ with a 64 bit target, or the other way around, you need to perform a `make distc
|
|||
|
||||
In case of build errors when trying to build a 32 bit binary of Redis, try the following steps:
|
||||
|
||||
* Install the package libc6-dev-i386 (also try g++-multilib).
|
||||
* Try using the following command line instead of `make 32bit`:
|
||||
- Install the package libc6-dev-i386 (also try g++-multilib).
|
||||
- Try using the following command line instead of `make 32bit`:
|
||||
`make CFLAGS="-m32 -march=native" LDFLAGS="-m32"`
|
||||
|
||||
### Allocator
|
||||
|
||||
Selecting a non-default memory allocator when building Redis is done by setting the `MALLOC` environment variable. Redis is compiled and linked against libc malloc by default, with the exception of jemalloc being the default on Linux systems. This default was picked because jemalloc has proven to have fewer fragmentation problems than libc malloc.
|
||||
Selecting a non-default memory allocator when building Redis is done by setting the `MALLOC` environment variable. Redis is compiled and linked against libc malloc by default, except for jemalloc being the default on Linux systems. This default was picked because jemalloc has proven to have fewer fragmentation problems than libc malloc.
|
||||
|
||||
To force compiling against libc malloc, use:
|
||||
|
||||
```
|
||||
```sh
|
||||
make MALLOC=libc
|
||||
```
|
||||
|
||||
To compile against jemalloc on Mac OS X systems, use:
|
||||
|
||||
```
|
||||
```sh
|
||||
make MALLOC=jemalloc
|
||||
```
|
||||
|
||||
### Monotonic clock
|
||||
|
||||
By default, Redis will build using the POSIX clock_gettime function as the monotonic clock source. On most modern systems, the internal processor clock can be used to improve performance. Cautions can be found here: http://oliveryang.net/2015/09/pitfalls-of-TSC-usage/
|
||||
By default, Redis will build using the POSIX clock_gettime function as the monotonic clock source. On most modern systems, the internal processor clock can be used to improve performance. Cautions can be found here: http://oliveryang.net/2015/09/pitfalls-of-TSC-usage/
|
||||
|
||||
To build with support for the processor's internal instruction clock, use:
|
||||
|
||||
```
|
||||
```sh
|
||||
make CFLAGS="-DUSE_PROCESSOR_CLOCK"
|
||||
```
|
||||
|
||||
|
@ -797,7 +818,7 @@ make CFLAGS="-DUSE_PROCESSOR_CLOCK"
|
|||
Redis will build with a user-friendly colorized output by default.
|
||||
If you want to see a more verbose output, use the following:
|
||||
|
||||
```
|
||||
```sh
|
||||
make V=1
|
||||
```
|
||||
|
||||
|
@ -805,7 +826,7 @@ make V=1
|
|||
|
||||
Please consult the [TLS.md](TLS.md) file for more information on how to use Redis with TLS.
|
||||
|
||||
### Code contributions
|
||||
## Code contributions
|
||||
|
||||
By contributing code to the Redis project in any form, including sending a pull request via GitHub, a code fragment or patch via private email or public discussion groups, you agree to release your code under the terms of the Redis Software Grant and Contributor License Agreement. Please see the CONTRIBUTING.md file in this source distribution for more information. For security bugs and vulnerabilities, please see SECURITY.md. Open Source Redis releases are subject to the following licenses:
|
||||
|
||||
|
@ -815,6 +836,6 @@ By contributing code to the Redis project in any form, including sending a pull
|
|||
|
||||
3. Version 8.0.x and subsequent releases are subject to the tri-license RSALv2/SSPLv1/AGPLv3 at your option as referenced in the LICENSE.txt file.
|
||||
|
||||
### Redis Trademarks
|
||||
## Redis Trademarks
|
||||
|
||||
The purpose of a trademark is to identify the goods and services of a person or company without causing confusion. As the registered owner of its name and logo, Redis accepts certain limited uses of its trademarks but it has requirements that must be followed as described in its Trademark Guidelines available at: https://redis.io/legal/trademark-policy/.
|
||||
The purpose of a trademark is to identify the goods and services of a person or company without causing confusion. As the registered owner of its name and logo, Redis accepts certain limited uses of its trademarks, but it has requirements that must be followed as described in its Trademark Guidelines available at: https://redis.io/legal/trademark-policy/.
|
||||
|
|
|
@ -12,6 +12,23 @@ BINCOLOR="\033[37;1m"
|
|||
MAKECOLOR="\033[32;1m"
|
||||
ENDCOLOR="\033[0m"
|
||||
|
||||
DEPS_CFLAGS := $(CFLAGS)
|
||||
DEPS_LDFLAGS := $(LDFLAGS)
|
||||
CLANG := $(findstring clang,$(shell sh -c '$(CC) --version | head -1'))
|
||||
|
||||
# MSan looks for errors related to uninitialized memory.
|
||||
# Make sure to build the dependencies with MSan as it needs all the code to be instrumented.
|
||||
# A library could be used to initialize memory but if it's not build with --fsanitize=memory then
|
||||
# MSan doesn't know about it and will spit false positive error when that memory is then used.
|
||||
ifeq ($(SANITIZER),memory)
|
||||
ifeq (clang, $(CLANG))
|
||||
DEPS_CFLAGS+=-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-sanitize-recover=all -fno-omit-frame-pointer
|
||||
DEPS_LDFLAGS+=-fsanitize=memory
|
||||
else
|
||||
$(error "MemorySanitizer needs to be compiled and linked with clang. Please use CC=clang")
|
||||
endif
|
||||
endif
|
||||
|
||||
default:
|
||||
@echo "Explicit target required"
|
||||
|
||||
|
@ -53,31 +70,31 @@ endif
|
|||
|
||||
hiredis: .make-prerequisites
|
||||
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
||||
cd hiredis && $(MAKE) static $(HIREDIS_MAKE_FLAGS)
|
||||
cd hiredis && $(MAKE) static $(HIREDIS_MAKE_FLAGS) CFLAGS="$(DEPS_CFLAGS)" LDFLAGS="$(DEPS_LDFLAGS)"
|
||||
|
||||
.PHONY: hiredis
|
||||
|
||||
linenoise: .make-prerequisites
|
||||
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
||||
cd linenoise && $(MAKE)
|
||||
cd linenoise && $(MAKE) CFLAGS="$(DEPS_CFLAGS)" LDFLAGS="$(DEPS_LDFLAGS)"
|
||||
|
||||
.PHONY: linenoise
|
||||
|
||||
hdr_histogram: .make-prerequisites
|
||||
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
||||
cd hdr_histogram && $(MAKE)
|
||||
cd hdr_histogram && $(MAKE) CFLAGS="$(DEPS_CFLAGS)" LDFLAGS="$(DEPS_LDFLAGS)"
|
||||
|
||||
.PHONY: hdr_histogram
|
||||
|
||||
fpconv: .make-prerequisites
|
||||
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
||||
cd fpconv && $(MAKE)
|
||||
cd fpconv && $(MAKE) CFLAGS="$(DEPS_CFLAGS)" LDFLAGS="$(DEPS_LDFLAGS)"
|
||||
|
||||
.PHONY: fpconv
|
||||
|
||||
fast_float: .make-prerequisites
|
||||
@printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR)
|
||||
cd fast_float && $(MAKE) libfast_float
|
||||
cd fast_float && $(MAKE) libfast_float CFLAGS="$(DEPS_CFLAGS)" LDFLAGS="$(DEPS_LDFLAGS)"
|
||||
|
||||
.PHONY: fast_float
|
||||
|
||||
|
@ -86,8 +103,8 @@ ifeq ($(uname_S),SunOS)
|
|||
LUA_CFLAGS= -D__C99FEATURES__=1
|
||||
endif
|
||||
|
||||
LUA_CFLAGS+= -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP $(CFLAGS)
|
||||
LUA_LDFLAGS+= $(LDFLAGS)
|
||||
LUA_CFLAGS+= -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP $(DEPS_CFLAGS)
|
||||
LUA_LDFLAGS+= $(DEPS_LDFLAGS)
|
||||
ifeq ($(LUA_DEBUG),yes)
|
||||
LUA_CFLAGS+= -O0 -g -DLUA_USE_APICHECK
|
||||
else
|
||||
|
|
12
src/Makefile
12
src/Makefile
|
@ -118,12 +118,24 @@ else
|
|||
ifeq ($(SANITIZER),thread)
|
||||
CFLAGS+=-fsanitize=thread -fno-sanitize-recover=all -fno-omit-frame-pointer
|
||||
LDFLAGS+=-fsanitize=thread
|
||||
else
|
||||
ifeq ($(SANITIZER),memory)
|
||||
ifeq (clang, $(CLANG))
|
||||
export CXX:=clang
|
||||
export LD:=clang
|
||||
MALLOC=libc # MSan provides its own allocator so make sure not to use jemalloc as they clash
|
||||
CFLAGS+=-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-sanitize-recover=all -fno-omit-frame-pointer
|
||||
LDFLAGS+=-fsanitize=memory
|
||||
else
|
||||
$(error "MemorySanitizer needs to be compiled and linked with clang. Please use CC=clang")
|
||||
endif
|
||||
else
|
||||
$(error "unknown sanitizer=${SANITIZER}")
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Override default settings if possible
|
||||
-include .make-settings
|
||||
|
|
|
@ -1725,7 +1725,10 @@ cleanup:
|
|||
if (fakeClient) freeClient(fakeClient);
|
||||
server.current_client = old_cur_client;
|
||||
server.executing_client = old_exec_client;
|
||||
int fd = dup(fileno(fp));
|
||||
fclose(fp);
|
||||
/* Reclaim page cache memory used by the AOF file in background. */
|
||||
if (fd >= 0) bioCreateCloseJob(fd, 0, 1);
|
||||
sdsfree(aof_filepath);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
*
|
||||
* In the future we'll either continue implementing new things we need or
|
||||
* we'll switch to libeio. However there are probably long term uses for this
|
||||
* file as we may want to put here Redis specific background tasks.
|
||||
* file as we may want to put Redis specific background tasks here.
|
||||
*
|
||||
* DESIGN
|
||||
* ------
|
||||
|
|
|
@ -3,10 +3,15 @@
|
|||
* Copyright (c) 2009-Present, Redis Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2024-present, Valkey contributors.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under your choice of (a) the Redis Source Available License 2.0
|
||||
* (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the
|
||||
* GNU Affero General Public License v3 (AGPLv3).
|
||||
*
|
||||
* Portions of this file are available under BSD3 terms; see REDISCONTRIBUTIONS for more information.
|
||||
*
|
||||
* ---------------------------------------------------------------------------
|
||||
*
|
||||
* API:
|
||||
|
@ -88,6 +93,7 @@ void updateStatsOnUnblock(client *c, long blocked_us, long reply_us, int had_err
|
|||
const ustime_t total_cmd_duration = c->duration + blocked_us + reply_us;
|
||||
c->lastcmd->microseconds += total_cmd_duration;
|
||||
c->lastcmd->calls++;
|
||||
c->commands_processed++;
|
||||
server.stat_numcommands++;
|
||||
if (had_errors)
|
||||
c->lastcmd->failed_calls++;
|
||||
|
|
|
@ -168,6 +168,12 @@
|
|||
#define REDIS_NO_SANITIZE(sanitizer)
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
#define REDIS_NO_SANITIZE_MSAN(sanitizer) REDIS_NO_SANITIZE(sanitizer)
|
||||
#else
|
||||
#define REDIS_NO_SANITIZE_MSAN(sanitizer)
|
||||
#endif
|
||||
|
||||
/* Define rdb_fsync_range to sync_file_range() on Linux, otherwise we use
|
||||
* the plain fsync() call. */
|
||||
#if (defined(__linux__) && defined(SYNC_FILE_RANGE_WAIT_BEFORE))
|
||||
|
|
|
@ -1378,6 +1378,7 @@ static void* getAndSetMcontextEip(ucontext_t *uc, void *eip) {
|
|||
#undef NOT_SUPPORTED
|
||||
}
|
||||
|
||||
REDIS_NO_SANITIZE_MSAN("memory")
|
||||
REDIS_NO_SANITIZE("address")
|
||||
void logStackContent(void **sp) {
|
||||
if (server.hide_user_data_from_log) {
|
||||
|
@ -2729,7 +2730,7 @@ static size_t get_ready_to_signal_threads_tids(int sig_num, pid_t tids[TIDS_MAX_
|
|||
pid_t calling_tid = syscall(SYS_gettid);
|
||||
int current_thread_index = -1;
|
||||
long nread;
|
||||
char buff[PATH_MAX];
|
||||
char buff[PATH_MAX] = {0};
|
||||
|
||||
/* readdir() is not async-signal-safe (AS-safe).
|
||||
Hence, we read the file using SYS_getdents64, which is considered AS-sync*/
|
||||
|
|
|
@ -96,6 +96,12 @@
|
|||
# define NO_SANITIZE(sanitizer)
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
#define NO_SANITIZE_MSAN(sanitizer) NO_SANITIZE(sanitizer)
|
||||
#else
|
||||
#define NO_SANITIZE_MSAN(sanitizer)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* compressed format
|
||||
*
|
||||
|
@ -105,6 +111,7 @@
|
|||
*
|
||||
*/
|
||||
NO_SANITIZE("alignment")
|
||||
NO_SANITIZE_MSAN("memory")
|
||||
size_t
|
||||
lzf_compress (const void *const in_data, size_t in_len,
|
||||
void *out_data, size_t out_len
|
||||
|
|
|
@ -36,16 +36,6 @@
|
|||
#define ULONG_ZEROONE 0x5555555555555555UL
|
||||
#endif
|
||||
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(no_sanitize)
|
||||
#define NO_SANITIZE(sanitizer) __attribute__((no_sanitize(sanitizer)))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(NO_SANITIZE)
|
||||
#define NO_SANITIZE(sanitizer)
|
||||
#endif
|
||||
|
||||
static struct winsize ws;
|
||||
size_t progress_printed; /* Printed chars in screen-wide progress bar. */
|
||||
size_t progress_full; /* How many chars to write to fill the progress bar. */
|
||||
|
@ -268,7 +258,7 @@ int memtest_test(unsigned long *m, size_t bytes, int passes, int interactive) {
|
|||
* the cache. */
|
||||
#define MEMTEST_DECACHE_SIZE (1024*8)
|
||||
|
||||
NO_SANITIZE("undefined")
|
||||
REDIS_NO_SANITIZE("undefined")
|
||||
int memtest_preserving_test(unsigned long *m, size_t bytes, int passes) {
|
||||
unsigned long backup[MEMTEST_BACKUP_WORDS];
|
||||
unsigned long *p = m;
|
||||
|
|
|
@ -222,6 +222,9 @@ client *createClient(connection *conn) {
|
|||
c->mem_usage_bucket_node = NULL;
|
||||
if (conn) linkClient(c);
|
||||
initClientMultiState(c);
|
||||
c->net_input_bytes = 0;
|
||||
c->net_output_bytes = 0;
|
||||
c->commands_processed = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -2141,6 +2144,7 @@ int writeToClient(client *c, int handler_installed) {
|
|||
}
|
||||
atomicIncr(server.stat_net_output_bytes, totwritten);
|
||||
}
|
||||
c->net_output_bytes += totwritten;
|
||||
|
||||
if (nwritten == -1) {
|
||||
if (connGetState(c->conn) != CONN_STATE_CONNECTED) {
|
||||
|
@ -2983,6 +2987,7 @@ void readQueryFromClient(connection *conn) {
|
|||
} else {
|
||||
atomicIncr(server.stat_net_input_bytes, nread);
|
||||
}
|
||||
c->net_input_bytes += nread;
|
||||
|
||||
if (!(c->flags & CLIENT_MASTER) &&
|
||||
/* The commands cached in the MULTI/EXEC queue have not been executed yet,
|
||||
|
@ -3158,7 +3163,10 @@ sds catClientInfoString(sds s, client *client) {
|
|||
" resp=%i", client->resp,
|
||||
" lib-name=%s", client->lib_name ? (char*)client->lib_name->ptr : "",
|
||||
" lib-ver=%s", client->lib_ver ? (char*)client->lib_ver->ptr : "",
|
||||
" io-thread=%i", client->tid));
|
||||
" io-thread=%i", client->tid,
|
||||
" tot-net-in=%U", client->net_input_bytes,
|
||||
" tot-net-out=%U", client->net_output_bytes,
|
||||
" tot-cmds=%U", client->commands_processed));
|
||||
|
||||
if (paused) resumeIOThread(client->running_tid);
|
||||
return ret;
|
||||
|
|
|
@ -438,6 +438,7 @@ static void clientDone(client c) {
|
|||
}
|
||||
}
|
||||
|
||||
REDIS_NO_SANITIZE_MSAN("memory")
|
||||
static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
|
||||
client c = privdata;
|
||||
void *reply = NULL;
|
||||
|
|
|
@ -3819,8 +3819,14 @@ void call(client *c, int flags) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!(c->flags & CLIENT_BLOCKED))
|
||||
if (!(c->flags & CLIENT_BLOCKED)) {
|
||||
/* Modules may call commands in cron, in which case server.current_client
|
||||
* is not set. */
|
||||
if (server.current_client) {
|
||||
server.current_client->commands_processed++;
|
||||
}
|
||||
server.stat_numcommands++;
|
||||
}
|
||||
|
||||
/* Record peak memory after each command and before the eviction that runs
|
||||
* before the next command. */
|
||||
|
|
|
@ -1413,6 +1413,9 @@ typedef struct client {
|
|||
#ifdef LOG_REQ_RES
|
||||
clientReqResInfo reqres;
|
||||
#endif
|
||||
unsigned long long net_input_bytes; /* Total network input bytes read from this client. */
|
||||
unsigned long long net_output_bytes; /* Total network output bytes sent to this client. */
|
||||
unsigned long long commands_processed; /* Total count of commands this client executed. */
|
||||
} client;
|
||||
|
||||
typedef struct __attribute__((aligned(CACHE_LINE_SIZE))) {
|
||||
|
@ -3458,7 +3461,6 @@ uint64_t hfieldGetExpireTime(hfield field);
|
|||
static inline void hfieldFree(hfield field) { mstrFree(&mstrFieldKind, field); }
|
||||
static inline void *hfieldGetAllocPtr(hfield field) { return mstrGetAllocPtr(&mstrFieldKind, field); }
|
||||
static inline size_t hfieldlen(hfield field) { return mstrlen(field);}
|
||||
uint64_t hfieldGetExpireTime(hfield field);
|
||||
|
||||
/* Pub / Sub */
|
||||
int pubsubUnsubscribeAllChannels(client *c, int notify);
|
||||
|
|
|
@ -891,7 +891,6 @@ int hashTypeExists(redisDb *db, robj *o, sds field, int hfeFlags, int *isHashDel
|
|||
#define HASH_SET_TAKE_FIELD (1<<0)
|
||||
#define HASH_SET_TAKE_VALUE (1<<1)
|
||||
#define HASH_SET_KEEP_TTL (1<<2)
|
||||
#define HASH_SET_COPY 0
|
||||
int hashTypeSet(redisDb *db, robj *o, sds field, sds value, int flags) {
|
||||
int update = 0;
|
||||
|
||||
|
|
46
src/t_set.c
46
src/t_set.c
|
@ -74,8 +74,8 @@ static void maybeConvertToIntset(robj *set) {
|
|||
if (setTypeSize(set) > intsetMaxEntries()) return; /* can't use intset */
|
||||
intset *is = intsetNew();
|
||||
char *str;
|
||||
size_t len;
|
||||
int64_t llval;
|
||||
size_t len = 0;
|
||||
int64_t llval = 0;
|
||||
setTypeIterator *si = setTypeInitIterator(set);
|
||||
while (setTypeNext(si, &str, &len, &llval) != -1) {
|
||||
if (str) {
|
||||
|
@ -371,7 +371,7 @@ int setTypeNext(setTypeIterator *si, char **str, size_t *len, int64_t *llele) {
|
|||
}
|
||||
if (lpi == NULL) return -1;
|
||||
si->lpi = lpi;
|
||||
unsigned int l;
|
||||
unsigned int l = 0;
|
||||
*str = (char *)lpGetValue(lpi, &l, (long long *)llele);
|
||||
*len = (size_t)l;
|
||||
} else {
|
||||
|
@ -388,9 +388,9 @@ int setTypeNext(setTypeIterator *si, char **str, size_t *len, int64_t *llele) {
|
|||
* This function is the way to go for write operations where COW is not
|
||||
* an issue. */
|
||||
sds setTypeNextObject(setTypeIterator *si) {
|
||||
int64_t intele;
|
||||
int64_t intele = 0;
|
||||
char *str;
|
||||
size_t len;
|
||||
size_t len = 0;
|
||||
|
||||
if (setTypeNext(si, &str, &len, &intele) == -1) return NULL;
|
||||
if (str != NULL) return sdsnewlen(str, len);
|
||||
|
@ -522,8 +522,8 @@ int setTypeConvertAndExpand(robj *setobj, int enc, unsigned long cap, int panic)
|
|||
}
|
||||
unsigned char *lp = lpNew(estcap);
|
||||
char *str;
|
||||
size_t len;
|
||||
int64_t llele;
|
||||
size_t len = 0;
|
||||
int64_t llele = 0;
|
||||
si = setTypeInitIterator(setobj);
|
||||
while (setTypeNext(si, &str, &len, &llele) != -1) {
|
||||
if (str != NULL)
|
||||
|
@ -574,8 +574,8 @@ robj *setTypeDup(robj *o) {
|
|||
dictExpand(set->ptr, dictSize(d));
|
||||
si = setTypeInitIterator(o);
|
||||
char *str;
|
||||
size_t len;
|
||||
int64_t intobj;
|
||||
size_t len = 0;
|
||||
int64_t intobj = 0;
|
||||
while (setTypeNext(si, &str, &len, &intobj) != -1) {
|
||||
setTypeAdd(set, (sds)str);
|
||||
}
|
||||
|
@ -818,8 +818,8 @@ void spopWithCountCommand(client *c) {
|
|||
|
||||
/* Common iteration vars. */
|
||||
char *str;
|
||||
size_t len;
|
||||
int64_t llele;
|
||||
size_t len = 0;
|
||||
int64_t llele = 0;
|
||||
unsigned long remaining = size-count; /* Elements left after SPOP. */
|
||||
|
||||
/* If we are here, the number of requested elements is less than the
|
||||
|
@ -839,7 +839,7 @@ void spopWithCountCommand(client *c) {
|
|||
unsigned char **ps = zmalloc(sizeof(char *) * count);
|
||||
for (unsigned long i = 0; i < count; i++) {
|
||||
p = lpNextRandom(lp, p, &index, count - i, 1);
|
||||
unsigned int len;
|
||||
unsigned int len = 0;
|
||||
str = (char *)lpGetValue(p, &len, (long long *)&llele);
|
||||
|
||||
if (str) {
|
||||
|
@ -903,7 +903,7 @@ void spopWithCountCommand(client *c) {
|
|||
unsigned char **ps = zmalloc(sizeof(char *) * remaining);
|
||||
for (unsigned long i = 0; i < remaining; i++) {
|
||||
p = lpNextRandom(lp, p, &index, remaining - i, 1);
|
||||
unsigned int len;
|
||||
unsigned int len = 0;
|
||||
str = (char *)lpGetValue(p, &len, (long long *)&llele);
|
||||
setTypeAddAux(newset, str, len, llele, 0);
|
||||
ps[i] = p;
|
||||
|
@ -1031,8 +1031,8 @@ void srandmemberWithCountCommand(client *c) {
|
|||
int uniq = 1;
|
||||
robj *set;
|
||||
char *str;
|
||||
size_t len;
|
||||
int64_t llele;
|
||||
size_t len = 0;
|
||||
int64_t llele = 0;
|
||||
|
||||
dict *d;
|
||||
|
||||
|
@ -1233,8 +1233,8 @@ void srandmemberWithCountCommand(client *c) {
|
|||
void srandmemberCommand(client *c) {
|
||||
robj *set;
|
||||
char *str;
|
||||
size_t len;
|
||||
int64_t llele;
|
||||
size_t len = 0;
|
||||
int64_t llele = 0;
|
||||
|
||||
if (c->argc == 3) {
|
||||
srandmemberWithCountCommand(c);
|
||||
|
@ -1289,8 +1289,8 @@ void sinterGenericCommand(client *c, robj **setkeys,
|
|||
setTypeIterator *si;
|
||||
robj *dstset = NULL;
|
||||
char *str;
|
||||
size_t len;
|
||||
int64_t intobj;
|
||||
size_t len = 0;
|
||||
int64_t intobj = 0;
|
||||
void *replylen = NULL;
|
||||
unsigned long j, cardinality = 0;
|
||||
int encoding, empty = 0;
|
||||
|
@ -1454,8 +1454,8 @@ void sinterCommand(client *c) {
|
|||
void smembersCommand(client *c) {
|
||||
setTypeIterator *si;
|
||||
char *str;
|
||||
size_t len;
|
||||
int64_t intobj;
|
||||
size_t len = 0;
|
||||
int64_t intobj = 0;
|
||||
robj *setobj = lookupKeyRead(c->db, c->argv[1]);
|
||||
if (checkType(c,setobj,OBJ_SET)) return;
|
||||
if (!setobj) {
|
||||
|
@ -1524,8 +1524,8 @@ void sunionDiffGenericCommand(client *c, robj **setkeys, int setnum,
|
|||
robj *dstset = NULL;
|
||||
int dstset_encoding = OBJ_ENCODING_INTSET;
|
||||
char *str;
|
||||
size_t len;
|
||||
int64_t llval;
|
||||
size_t len = 0;
|
||||
int64_t llval = 0;
|
||||
int encoding;
|
||||
int j, cardinality = 0;
|
||||
int diff_algo = 1;
|
||||
|
|
|
@ -257,7 +257,7 @@ static inline int64_t lpGetIntegerIfValid(unsigned char *ele, int *valid) {
|
|||
/* The following code path should never be used for how listpacks work:
|
||||
* they should always be able to store an int64_t value in integer
|
||||
* encoded form. However the implementation may change. */
|
||||
long long ll;
|
||||
long long ll = 0;
|
||||
int ret = string2ll((char*)e,v,&ll);
|
||||
if (valid)
|
||||
*valid = ret;
|
||||
|
|
|
@ -11,9 +11,27 @@ else # Linux, others
|
|||
SHOBJ_LDFLAGS ?= -shared
|
||||
endif
|
||||
|
||||
CLANG := $(findstring clang,$(shell sh -c '$(CC) --version | head -1'))
|
||||
|
||||
ifeq ($(SANITIZER),memory)
|
||||
ifeq (clang, $(CLANG))
|
||||
LD=clang
|
||||
MALLOC=libc
|
||||
CFLAGS+=-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-sanitize-recover=all -fno-omit-frame-pointer
|
||||
LDFLAGS+=-fsanitize=memory
|
||||
else
|
||||
$(error "MemorySanitizer needs to be compiled and linked with clang. Please use CC=clang")
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
# This is a hack to override the default CC. When running with SANITIZER=memory
|
||||
# tough we want to keep the compiler as clang as MSan is not supported for gcc
|
||||
ifeq ($(uname_S),Linux)
|
||||
LD = gcc
|
||||
CC = gcc
|
||||
ifneq ($(SANITIZER),memory)
|
||||
LD = gcc
|
||||
CC = gcc
|
||||
endif
|
||||
endif
|
||||
|
||||
# OS X 11.x doesn't have /usr/lib/libSystem.dylib and needs an explicit setting.
|
||||
|
|
|
@ -294,7 +294,7 @@ proc spawn_server {config_file stdout stderr args} {
|
|||
# ASAN_OPTIONS environment variable is for address sanitizer. If a test
|
||||
# tries to allocate huge memory area and expects allocator to return
|
||||
# NULL, address sanitizer throws an error without this setting.
|
||||
set pid [exec /usr/bin/env ASAN_OPTIONS=allocator_may_return_null=1 {*}$cmd >> $stdout 2>> $stderr &]
|
||||
set pid [exec /usr/bin/env ASAN_OPTIONS=allocator_may_return_null=1 MSAN_OPTIONS=allocator_may_return_null=1 {*}$cmd >> $stdout 2>> $stderr &]
|
||||
}
|
||||
|
||||
if {$::wait_server} {
|
||||
|
|
|
@ -70,11 +70,15 @@ proc sanitizer_errors_from_file {filename} {
|
|||
set lines [split [exec cat $filename] "\n"]
|
||||
|
||||
foreach line $lines {
|
||||
# Ignore huge allocation warnings
|
||||
# Ignore huge allocation warnings for both ASan and MSan
|
||||
if ([string match {*WARNING: AddressSanitizer failed to allocate*} $line]) {
|
||||
continue
|
||||
}
|
||||
|
||||
if ([string match {*WARNING: MemorySanitizer failed to allocate*} $line]) {
|
||||
continue
|
||||
}
|
||||
|
||||
# GCC UBSAN output does not contain 'Sanitizer' but 'runtime error'.
|
||||
if {[string match {*runtime error*} $line] ||
|
||||
[string match {*Sanitizer*} $line]} {
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
#
|
||||
# Copyright (c) 2009-Present, Redis Ltd.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Copyright (c) 2024-present, Valkey contributors.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Licensed under your choice of the Redis Source Available License 2.0
|
||||
# (RSALv2) or the Server Side Public License v1 (SSPLv1).
|
||||
#
|
||||
# Portions of this file are available under BSD3 terms; see REDISCONTRIBUTIONS for more information.
|
||||
#
|
||||
|
||||
start_server {tags {"introspection"}} {
|
||||
test "PING" {
|
||||
assert_equal {PONG} [r ping]
|
||||
|
@ -8,9 +21,9 @@ start_server {tags {"introspection"}} {
|
|||
test {CLIENT LIST} {
|
||||
set client_list [r client list]
|
||||
if {[lindex [r config get io-threads] 1] == 1} {
|
||||
assert_match {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=26 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|list user=* redir=-1 resp=*} $client_list
|
||||
assert_match {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=26 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|list user=* redir=-1 resp=* lib-name=* lib-ver=* io-thread=* tot-net-in=* tot-net-out=* tot-cmds=*} $client_list
|
||||
} else {
|
||||
assert_match {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=0 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|list user=* redir=-1 resp=*} $client_list
|
||||
assert_match {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=0 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|list user=* redir=-1 resp=* lib-name=* lib-ver=* io-thread=* tot-net-in=* tot-net-out=* tot-cmds=*} $client_list
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,12 +36,111 @@ start_server {tags {"introspection"}} {
|
|||
test {CLIENT INFO} {
|
||||
set client [r client info]
|
||||
if {[lindex [r config get io-threads] 1] == 1} {
|
||||
assert_match {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=26 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|info user=* redir=-1 resp=*} $client
|
||||
assert_match {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=26 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|info user=* redir=-1 resp=* lib-name=* lib-ver=* io-thread=* tot-net-in=* tot-net-out=* tot-cmds=*} $client
|
||||
} else {
|
||||
assert_match {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=0 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|info user=* redir=-1 resp=*} $client
|
||||
assert_match {id=* addr=*:* laddr=*:* fd=* name=* age=* idle=* flags=N db=* sub=0 psub=0 ssub=0 multi=-1 watch=0 qbuf=0 qbuf-free=* argv-mem=* multi-mem=0 rbs=* rbp=* obl=0 oll=0 omem=0 tot-mem=* events=r cmd=client|info user=* redir=-1 resp=* lib-name=* lib-ver=* io-thread=* tot-net-in=* tot-net-out=* tot-cmds=*} $client
|
||||
}
|
||||
}
|
||||
|
||||
proc get_field_in_client_info {info field} {
|
||||
set info [string trim $info]
|
||||
foreach item [split $info " "] {
|
||||
set kv [split $item "="]
|
||||
set k [lindex $kv 0]
|
||||
if {[string match $field $k]} {
|
||||
return [lindex $kv 1]
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
proc get_field_in_client_list {id client_list filed} {
|
||||
set list [split $client_list "\r\n"]
|
||||
foreach info $list {
|
||||
if {[string match "id=$id *" $info] } {
|
||||
return [get_field_in_client_info $info $filed]
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
test {CLIENT INFO input/output/cmds-processed stats} {
|
||||
set info1 [r client info]
|
||||
set input1 [get_field_in_client_info $info1 "tot-net-in"]
|
||||
set output1 [get_field_in_client_info $info1 "tot-net-out"]
|
||||
set cmd1 [get_field_in_client_info $info1 "tot-cmds"]
|
||||
|
||||
# Run a command by that client and test if the stats change correctly
|
||||
set info2 [r client info]
|
||||
set input2 [get_field_in_client_info $info2 "tot-net-in"]
|
||||
set output2 [get_field_in_client_info $info2 "tot-net-out"]
|
||||
set cmd2 [get_field_in_client_info $info2 "tot-cmds"]
|
||||
|
||||
# NOTE if CLIENT INFO changes it's stats the output_bytes here and in the
|
||||
# other related tests will need to be updated.
|
||||
set input_bytes 26 ; # CLIENT INFO request
|
||||
set output_bytes 300 ; # CLIENT INFO result
|
||||
set cmds_processed 1 ; # processed the command CLIENT INFO
|
||||
assert_equal [expr $input1+$input_bytes] $input2
|
||||
assert {[expr $output1+$output_bytes] < $output2}
|
||||
assert_equal [expr $cmd1+$cmds_processed] $cmd2
|
||||
}
|
||||
|
||||
test {CLIENT INFO input/output/cmds-processed stats for blocking command} {
|
||||
r del mylist
|
||||
set rd [redis_deferring_client]
|
||||
$rd client id
|
||||
set rd_id [$rd read]
|
||||
|
||||
set info_list [r client list]
|
||||
set input1 [get_field_in_client_list $rd_id $info_list "tot-net-in"]
|
||||
set output1 [get_field_in_client_list $rd_id $info_list "tot-net-out"]
|
||||
set cmd1 [get_field_in_client_list $rd_id $info_list "tot-cmds"]
|
||||
$rd blpop mylist 0
|
||||
|
||||
# Make sure to wait for the $rd client to be blocked
|
||||
wait_for_blocked_client
|
||||
|
||||
# Check if input stats have changed for $rd. Since command is blocking
|
||||
# and has not been unblocked yet we expect no change in output/cmds-processed
|
||||
# stats.
|
||||
set info_list [r client list]
|
||||
set input2 [get_field_in_client_list $rd_id $info_list "tot-net-in"]
|
||||
set output2 [get_field_in_client_list $rd_id $info_list "tot-net-out"]
|
||||
set cmd2 [get_field_in_client_list $rd_id $info_list "tot-cmds"]
|
||||
assert_equal [expr $input1+34] $input2
|
||||
assert_equal $output1 $output2
|
||||
assert_equal $cmd1 $cmd2
|
||||
|
||||
# Unblock the $rd client (which will send a reply and thus update output
|
||||
# and cmd-processed stats).
|
||||
r lpush mylist a
|
||||
|
||||
# Note that the per-client stats are from the POV of the server. The
|
||||
# deferred client may have not read the response yet, but the stats
|
||||
# are still updated.
|
||||
set info_list [r client list]
|
||||
set input3 [get_field_in_client_list $rd_id $info_list "tot-net-in"]
|
||||
set output3 [get_field_in_client_list $rd_id $info_list "tot-net-out"]
|
||||
set cmd3 [get_field_in_client_list $rd_id $info_list "tot-cmds"]
|
||||
assert_equal $input2 $input3
|
||||
assert_equal [expr $output2+23] $output3
|
||||
assert_equal [expr $cmd2+1] $cmd3
|
||||
|
||||
$rd close
|
||||
}
|
||||
|
||||
test {CLIENT INFO cmds-processed stats for recursive command} {
|
||||
set info [r client info]
|
||||
set tot_cmd_before [get_field_in_client_info $info "tot-cmds"]
|
||||
r eval "redis.call('ping')" 0
|
||||
set info [r client info]
|
||||
set tot_cmd_after [get_field_in_client_info $info "tot-cmds"]
|
||||
|
||||
# We executed 3 commands - EVAL, which in turn executed PING and finally CLIENT INFO
|
||||
assert_equal [expr $tot_cmd_before+3] $tot_cmd_after
|
||||
}
|
||||
|
||||
test {CLIENT KILL with illegal arguments} {
|
||||
assert_error "ERR wrong number of arguments for 'client|kill' command" {r client kill}
|
||||
assert_error "ERR syntax error*" {r client kill id 10 wrong_arg}
|
||||
|
|
Loading…
Reference in New Issue