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

Different cache rules to multiple groups #182

Open
rodolfovilaca opened this issue Jul 4, 2019 · 0 comments · May be fixed by #183
Open

Different cache rules to multiple groups #182

rodolfovilaca opened this issue Jul 4, 2019 · 0 comments · May be fixed by #183

Comments

@rodolfovilaca
Copy link

I don't know if it is a BUG or Enhancement feature.

Problem:

Today i have some services that i want to support different cache rules to different routes to my service, but as it is today in sortCaches function if i have different cache rules with groups it logs errors and return 0 cache rules to be applied.

if (generalCaches.length > 1) {
.

It doesn't allow me for example to do as follows:

name: 'My Service'
...
path: /my-service/
group:
    -
        id: TwoMinuteCache
        member:
            -
                method:
                    - GET
                path:
                    - get-something
    -
        id: TenMinuteCache
        member:
            -
                method:
                    - GET
                path:
                    - get-anotherthing
    -
        id: GeneralGroup
        member:
            -
                method:
                    - POST
                    - GET
                    - PUT
                    - DELETE
                    - OPTIONS
                protocol:
                    - http
                path:
                    - '!(get-something|get-anotherthing)'
proxy:
    target:
        host: 'http://172.18.0.1:port'
    timeout: '1 minute'
cache:
    -
        server:
            cacheTime: 10 minutes
            binary: true
        group:
            - TenMinuteCache
    -
        server:
            cacheTime: 2 minutes
            binary: true
        group:
            - TwoMinuteCache
            - GeneralGroup
throttling:
    -
        timeWindow: '1 minute'
        max: 100
authentication:
    strategy:
        name: jwt
        options:
            ...
    group:
        - GeneralGroup
        - TwoMinuteCache
        - TenMinuteCache
interceptor:
    request:
        -
            middleware:
                name: some-middleware

With this type of config today, it returns 0 cache rules and the gateway doesn't cache anything into redis.

As I said, i don't know if this is a intended behaviour or it is a BUG.

Solution

To support different cache rules to distinct paths we could do:

  • Check if exists another cache rule with the same group an throw an error, returning 0 cache rules.
  • Keep all cache rules and apply the last appearence by group and log a duplicate group cache rule warning.

I'm currently forking and posting my PR with the last option implemented, but we should discuss the best option to go from here.

@rodolfovilaca rodolfovilaca linked a pull request Jul 4, 2019 that will close this issue
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 a pull request may close this issue.

1 participant