Skip to content

Spike: KeyValue repository #1448

@bajtos

Description

@bajtos

Timeboxed to 3 days

See #1447

So far, LB4 persistence story is all about CRUD. Key-value stores are another common scenario we should support. LoopBack 3.x introduced KeyValue API and Redis + eXtremeScale connectors. For LoopBack 4, we need to add Repository implementations for KeyValue API and verify that all pieces work together as expected.

  • Add necessary Repository APIs and implementations
  • Verify the use case against real Redis instance
  • Documentation, example app, blog post

LB 3.x resources for reference:

Proposed repository API:

interface KeyFilter {
  match: string;
};

interface KeyValueRepository<T> {
  get(key: string, options?: object): Promise<T>;
  set(key: string, value: T, options: object & {ttl?: number}): Promise<void>;
  expire(key: string, ttl: number, options?: object): Promise<void>;
  ttl(key: string, options?: object): Promise<number>; // find a better name than ttl?

  iterateKeys(filter: KeyFilter, options?: object): AsyncIterator<T>;
  keys(filter: KeyFilter, options?: object): Promise<T[]>;
}

Acceptance criteria

  • Write a throw-away spike to find out how much work is needed to provide KeyValueRepository as an addition to EntityCrudRepository. Discuss the proposed implementation in a pull request, get it approved at least by @raymondfeng and @bajtos Raymond went ahead and opened a pull request providing a full implementation - see feat(repository): add KVRepository impl using legacy juggler #1539
  • Identify follow-up stories that are needed to make this functionality happen. Get the list approved before creating actual GitHub issues
  • Create a list of GitHub issues, make sure to include acceptance criteria in each one. Issues should be assigned to "Core-GA" release and Epic [Epic] KeyValue repository #1447.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions