basalt / subscriptions/src / MemoryCouponStore
Class: MemoryCouponStore
Defined in: subscriptions/src/coupon.ts:131
In-memory store — swap for a durable one in production.
Implements
Constructors
Constructor
> new MemoryCouponStore(): MemoryCouponStore
Returns
MemoryCouponStore
Methods
all()
> all(): Promise<CouponRecord[]>
Defined in: subscriptions/src/coupon.ts:141
Returns
Promise<CouponRecord[]>
Implementation of
get()
> get(code): Promise<CouponRecord | null>
Defined in: subscriptions/src/coupon.ts:137
Parameters
code
string
Returns
Promise<CouponRecord | null>
Implementation of
incrementRedemptions()
> incrementRedemptions(code, limit?): Promise<number | null>
Defined in: subscriptions/src/coupon.ts:144
Atomically increment the redemption counter; returns the new count. When limit is given, increment ONLY while the count is below it and return null when the cap is already reached — a single conditional write, so two concurrent redemptions of the last slot cannot both succeed. (A store that ignores limit still works: redeem() rejects a count above the cap, but the counter is then left one over.)
Parameters
code
string
limit?
number
Returns
Promise<number | null>
Implementation of
CouponStore.incrementRedemptions
save()
> save(coupon): Promise<void>
Defined in: subscriptions/src/coupon.ts:134
Parameters
coupon
Returns
Promise<void>