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

feat: pojo methods syntax #15

Merged
merged 6 commits into from
Apr 8, 2024
Merged

feat: pojo methods syntax #15

merged 6 commits into from
Apr 8, 2024

Conversation

Julien-R44
Copy link
Owner

Most of the methods now accept arguments in two different ways : either as a single argument or as an object.

If you need to pass some specific options, the object way is probably the best choice since it is more "vertical" and may be easier to read. On the other hand, the single argument may be more concise when you don't need to pass specific options.

Example :

// multiple arguments
await bento.getOrSet('products', () => fetchProducts(), {
  ttl: '5m',
  gracePeriod: { enabled: true, duration: '1m' },
})

// is equivalent to
await bento.getOrSet({
  key: 'products',
  ttl: '5m',
  factory: () => fetchProducts(),
  gracePeriod: { enabled: true, duration: '1m' },
})

Copy link

cloudflare-pages bot commented Apr 8, 2024

Deploying bentocache with  Cloudflare Pages  Cloudflare Pages

Latest commit: d8c55bc
Status: ✅  Deploy successful!
Preview URL: https://c203091e.bentocache.pages.dev
Branch Preview URL: https://feat-pojo-methods.bentocache.pages.dev

View logs

@Julien-R44 Julien-R44 merged commit 01d1d4b into main Apr 8, 2024
9 checks passed
@Julien-R44 Julien-R44 deleted the feat/pojo-methods branch April 8, 2024 00:20
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

Successfully merging this pull request may close these issues.

None yet

1 participant