Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Переосмысление core/cache #310

Open
kobezzza opened this issue Aug 3, 2022 · 0 comments
Open

Переосмысление core/cache #310

kobezzza opened this issue Aug 3, 2022 · 0 comments

Comments

@kobezzza
Copy link
Contributor

kobezzza commented Aug 3, 2022

Исторически, данный модуль вырос из потребности кешировать HTTP запросы, затем стал использоваться в других Cache кейзах.

Но сейчас стало понятно, что данных модуль хочется использоваться как более функциональную замену Map.
Поэтому нужно поправить ряд вещей:

  1. Перейти на более привычный порядок типовых параметров K,V (сейчас везде V, K) - https://github.com/V4Fire/Core/blob/master/src/core/cache/interface.ts#L19 . Тут нужно будет аккуратно везде пройтись и поправить.

  2. Уйти от трактовки K как строки по умолчанию - https://github.com/V4Fire/Core/blob/master/src/core/cache/interface.ts#L19
    https://github.com/V4Fire/Core/blob/master/src/core/cache/decorators/helpers/add-emitter/interface.ts#L28

  3. Очень хочется получить аналог default dict из python и тут можно расширить метод get

const cache = new Cache();

cache.get(key, defaultValue);
cache.get(key, () => defaultValue);
  1. Поправить вывод типов в декораторах. Сейчас почему то не выводится тип кеша.
// Cache<unknown, string>
const cache = addTTL(new Cache<string, string>(), 200);
  1. Добавить метод clone - возвращает кеш такого же типа, но клонированный.
@bunin-av bunin-av mentioned this issue Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant