Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
This repository was archived by the owner on May 20, 2025. It is now read-only.

Implement multiple backend option #14

@lucasrcezimbra

Description

@lucasrcezimbra

https://github.com/HBN3tw0rk/dcache/tree/master#multiple-backends

Ideia:

from dcache import dcache
from dcache.backends import InMemoryBackend, RedisBackend

@dcache(multiple=[
    InMemoryBackend(),
    RedisBackend(host='localhost', port=6379, db=0),
])
def slow_function(n):
        return n ** 1000
  1. search on the in-memory cache;
  2. if exists, return, if not, search on Redis;
    • if exists on Redis, save in memory and return;
    • if not, exists on Redis, run the slow_function, save on Redis, save in-memory and return;
  • doesn't run if already returned

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions