CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-google-cloud-ndb-redis

Type stubs for Google Cloud NDB Redis caching functionality - provides Redis cache implementation for NDB operations

Overview
Eval results
Files

Google Cloud NDB Redis Cache

Type stubs for Google Cloud NDB's Redis caching functionality. This package provides type annotations for the RedisCache class, which enables Redis-based global caching for Google Cloud NDB operations.

Package Information

  • Package Name: google-cloud-ndb
  • Package Type: Type stub package (PEP 561)
  • Language: Python
  • Installation: pip install google-cloud-ndb
  • Redis Cache: Part of the NDB global caching system

Core Imports

from google.cloud.ndb import RedisCache

Complete import for global cache types:

from google.cloud.ndb import GlobalCache, RedisCache, MemcacheCache

Basic Usage

from google.cloud.ndb import RedisCache
import redis

# Create Redis client
redis_client = redis.Redis(host='localhost', port=6379, db=0)

# Create Redis cache for NDB operations
cache = RedisCache(redis_client, strict_read=True, strict_write=True)

# Use with NDB context (typical usage)
from google.cloud import ndb

client = ndb.Client()
with client.context(global_cache=cache):
    # Your NDB operations will now use Redis caching
    pass

Architecture

The Google Cloud NDB Redis cache implementation provides a Redis-backed global cache for NDB operations:

  • GlobalCache Interface: Abstract base class defining the caching contract
  • RedisCache Implementation: Redis-specific implementation of global caching
  • Pipeline Support: Efficient batch operations using Redis pipelines
  • Error Handling: Transient error handling and strict read/write modes
  • Environment Configuration: Support for configuration via environment variables

Capabilities

Redis Cache Implementation

Redis-backed global cache implementation for Google Cloud NDB with support for all standard cache operations.

class RedisCache(GlobalCache):
    transient_errors: Any
    redis: Any
    strict_read: Any
    strict_write: Any
    
    def __init__(self, redis, strict_read: bool = ..., strict_write: bool = ...) -> None: ...
    
    @classmethod
    def from_environment(cls, strict_read: bool = ..., strict_write: bool = ...) -> Self: ...
    
    @property
    def pipes(self): ...
    
    def get(self, keys): ...
    def set(self, items, expires: Incomplete | None = ...) -> None: ...
    def delete(self, keys) -> None: ...
    def watch(self, items) -> None: ...
    def unwatch(self, keys) -> None: ...
    def compare_and_swap(self, items, expires: Incomplete | None = ...) -> None: ...
    def clear(self) -> None: ...

Redis Cache Operations

Types

import abc
from _typeshed import Incomplete
from typing import Any
from typing_extensions import Self

class GlobalCache(metaclass=abc.ABCMeta):
    """Abstract base class for global cache implementations."""
    __metaclass__: Any
    transient_errors: Any
    strict_read: bool
    strict_write: bool
    
    @abc.abstractmethod
    def get(self, keys): ...
    
    @abc.abstractmethod
    def set(self, items, expires: Incomplete | None = ...): ...
    
    @abc.abstractmethod
    def delete(self, keys): ...
    
    @abc.abstractmethod
    def watch(self, items): ...
    
    @abc.abstractmethod
    def unwatch(self, keys): ...
    
    @abc.abstractmethod
    def compare_and_swap(self, items, expires: Incomplete | None = ...): ...
    
    @abc.abstractmethod
    def clear(self): ...

class RedisCache(GlobalCache):
    """Redis implementation of GlobalCache for NDB operations."""
    transient_errors: Any
    redis: Any
    strict_read: Any
    strict_write: Any
    
    def __init__(self, redis, strict_read: bool = ..., strict_write: bool = ...) -> None: ...
    
    @classmethod
    def from_environment(cls, strict_read: bool = ..., strict_write: bool = ...) -> Self: ...

Install with Tessl CLI

npx tessl i tessl/pypi-google-cloud-ndb-redis
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/google-cloud-ndb@2.3.*