Skip to content

Create a generic Cache for other RPCs #18

@elliottwilliams

Description

@elliottwilliams

Other RPCs could benefit from cache: agency.* could remember lists of routes and stations before they're fetched (which is a very expensive call). Yet-to-be-implemented Schedule RPCs could retain schedule information without having to fetch.

This issue extends the infrastructure used by LastEventCache into a generic Cache with the following methods:

  • Cache.lookup(rpc:args:kwargs:) -> TopicEvent?
    Selects a cache for this particular rpc, and returns a stored TopicEvent if one exists matching the call argument.
  • Cache.store(rpc:args:kwargs:event:) -> Bool
    Selects a cache for rpc, and attempts to persist `event.
  • Cache.void(rpc:event:)
    Voids a stored event in the cache for rpc.

RPC-specific caches will implement a protocol with corresponding methods, as well as a test to determine if they accept a particular RPC. They can then be wired into a Connection.call middleware stack which tries each cache in order before trying the WAMP connection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions