Skip to content

Merge cache implementation classes for each backend #684

Closed
@padraic-shafer

Description

@padraic-shafer
Contributor

Background

Each backend cache implementation is currently split into two classes, with the "interface" class derived from the "backend" class.

  • SimpleMemoryCache subclasses SimpleMemoryBackend, which subclasses BaseCache[str].
  • MemcachedCache subclasses MemcachedBackend, which subclasses BaseCache[bytes].
  • RedisCache subclasses RedisBackend, which subclasses BaseCache[str].

Suggestion

Merge each pair into a single subclass of BaseClass. In other words, the ...Backend classes do not appear to provide any benefit or value by being distinct classes.

  • SimpleMemoryCache is highly bound to SimpleMemoryBackend, even in its name. It seems unlikely that anyone would use SimpleMemoryBackend directly, rather than using SimpleMemoryCache.
  • Also SimpleMemoryBackend does not appear to provide value as a base class for user customization. If a specialized memory cache is needed, one would probably derive from SimpleMemoryCache and override only what is needed, or derive from BaseCache if more extensive changes are required.

Question

Are any aiocache users relying on SimpleMemoryBackend, MemcachedBackend, RedisBackend classes, or could their functionality be merged into the corresponding ...Cache implementations?

Activity

added this to the 1.0 milestone on Mar 5, 2023
sakosha

sakosha commented on Jun 13, 2025

@sakosha
Contributor

Hello! Can I take this one?

Dreamsorcerer

Dreamsorcerer commented on Jun 13, 2025

@Dreamsorcerer
Member

Sure, go ahead. I'd leave the redis one till #975 is merged (probably any day now).

Dreamsorcerer

Dreamsorcerer commented on Jun 17, 2025

@Dreamsorcerer
Member

Redis/Valkey PR merged now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Participants

      @Dreamsorcerer@padraic-shafer@sakosha

      Issue actions

        Merge cache implementation classes for each backend · Issue #684 · aio-libs/aiocache