編輯

共用方式為


適用於 Python 的 Azure Redis 快取程式庫Azure Redis Cache libraries for Python

概觀Overview

Azure Redis 快取是以常用的開放原始碼 Redis 專案作為基礎。Azure Redis Cache is based on the popular open source Redis project. 它可讓您從 Azure 應用程式存取由 Microsoft 管理的安全、專用 Redis 執行個體。It gives you access to a secure, dedicated Redis instance, managed by Microsoft and accessible from your Azure apps.

Redis 是一種進階的索引鍵值存放區,其中的索引鍵可以包含類似字串、雜湊、清單、集合和排序的集合等資料結構。Redis is an advanced key-value store, where keys can contain data structures such as strings, hashes, lists, sets, and sorted sets. Redis 針對這些資料類型支援一組不可部分完成的操作。Redis supports a set of atomic operations on these data types.

深入了解 Azure Redis 快取Learn more about Azure Redis Cache.

管理 APIManagement API

使用 Redis 管理 API 在訂用帳戶中建立和管理 Redis 資源。Create and manage your Redis resources in your subscription with the Redis management API.

pip install redis
pip install azure-mgmt-redis

範例Example

下列範例會建立新的 Redis 快取:The following example creates a new Redis cache:

from azure.mgmt.redis import RedisManagementClient
from azure.mgmt.redis.models import Sku, RedisCreateOrUpdateParameters

redis_client = RedisManagementClient(
    credentials,
    subscription_id
)
group_name = 'myresourcegroup'
cache_name = 'mycachename'
redis_cache = redis_client.redis.create_or_update(
    group_name,
    cache_name,
    RedisCreateOrUpdateParameters(
        sku = Sku(name = 'Basic', family = 'C', capacity = '1'),
        location = "East US"
    )
)
# redis_cache is a RedisResourceWithAccessKey instance