Bucket4j JDBC integration #439
Replies: 1 comment 1 reply
-
You are free to use any type as primary key, for example: SQLProxyConfiguration<String> sqlConfiguration = SQLProxyConfiguration.builder()
.withPrimaryKeyMapper(PrimaryKeyMapper.STRING)
.withTableSettings(tableSettings)
.build(dataSource);
ProxyManager<String> proxyManager = new PostgreSQLadvisoryLockBasedProxyManager<>(sqlConfiguration) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello! I am new to bucket4j. I want to use it in my spring boot application that uses Spring MVC to use rate limiting on my APIs.
I have the following problem: I need to rate limit some APIs based on user role/subscription(for example, free,premium etc) but also some APIs need rate limiting based on IP. Is it possible to do this with bucket4j?
After reading the documentation, I assume I can use bucket id(long) to associate it with users - assign each user bucket id. Correct me if I am wrong. This should work for API rate limiting based on user's subscription/role. But what about IP address? How can I store it in the table if the primary key for bucket is id(long)? Should I find a way to convert IP to Long or can I just add additional nullable fields to the buckets table for ip address? Is there a better solution?
Beta Was this translation helpful? Give feedback.
All reactions