Skip to main content

bqredis

This library provides functionality to cache calls to bigquery with redis.

The use case which drove creation of this library was a web-based dashboard which pulled data from bigquery. Often queries were inexplicably slow. Even worse, a slow loading page would prompt users to refresh, would would saturate the available threadpools, further slowing the experience.

This is the result: a library which uses redis to cache bigquery results and prevents more than one inflight request from going out from a given cache instance at a time. Enough talking, let's cut to an example:

import bqredis

_QUERY = "SELECT * FROM `bigquery-public-data.country_codes.country_codes` ORDER BY alpha_3_code DESC LIMIT 10"

redis_client = redis.Redis.from_url("redis://localhost:6379")
cache = bqredis.BQRedis(redis_client, redis_cache_ttl_sec=300, redis_background_refresh_ttl_sec=5)
# Subsequent calls to this for the next 300 seconds will be cached.
cache.query_sync(_QUERY)
# Start a background refresh for this query.
promise = cache.submit_background_refresh(_QUERY)
promise.result()
# More calls for refreshing the background cache for the next 5 seconds will
# not start.

Return type

By default, this library will parse results as a pyarrow.RecordBatch. To instead use a different format, override the convert_arrow_to_output method. For example, to have results as a polars.DataFrame do the following:

import polars
import pyarrow

class BQRedisPolars(bqredis.BQRedis):
    def convert_arrow_to_output_format(self, records: pyarrow.RecordBatch) -> polars.DataFrame:
        return polars.from_arrow(records)

pl_cache = BQRedisPolars(redis_client, redis_cache_ttl_sec=300, redis_background_refresh_ttl_sec=5)
pl_cache.query_sync(_QUERY)

We use arrow as the underlying format because it is the direct format being sent by BigQuery. This can be converted with 0-copy to polars as show above.

Metadata

Release files for bqredis 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for bqredis 0.0.8
File Interpreter ABI Platform Actions
bqredis-0.0.8-py3-none-any.whl Python 3 none any Details for bqredis-0.0.8-py3-none-any.whl

Release files / bqredis-0.0.8-py3-none-any.whl

Download URL bqredis-0.0.8-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9188c380a3ddf0f2ea0bd6e3c864954b2694d9569d0f74badc3123b8b16d787a
BLAKE2b-256 checksum
How to use checksums
d146f6a197894eb6a10efe2787284bdbb0cade28cd8bb136c2293c64fab5fea5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 12, 2025.

Transparency log

Security for bqredis 0.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

1 file in this release has been uploaded with provenance metadata.

Attestation for bqredis-0.0.8-py3-none-any.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 12, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page