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

expire parameter in @Memoize* methods should parseLong, not parseInt #5

Closed
ajbrown opened this issue Feb 29, 2012 · 4 comments
Closed

Comments

@ajbrown
Copy link

ajbrown commented Feb 29, 2012

It appears that the expire parameter is expected to be an Integer. Since the expire time is in milliseconds, it should be expected to be a Long in order to support bigger expire times.

This breaks (expire in 60 days):
@memoize( key="autocomplete:#{query}", expire='5184000000' )

with a NumberFormatException

This works fine
@memoize( key="autocomplete:#{query}", expire='5184000' )

It looks like the problem is in line 62 of MemoizeASTTransformation.groovy:
argumentListExpression.addExpression(makeConstantExpression(Integer.parseInt(memoizeProperties.get(EXPIRE).toString())))

I will attempt a fix and open a pull request.

@tednaleid
Copy link
Contributor

Thanks, I agree that a Long is better for that situation. Most of my expires aren't more than a day out so I hadn't hit that issue. I look forward to the pull request if you've got time to do it.

As a temporary fix, you could use the non-memoized version of the api (per my other e-mail to you) and get around that, I believe it uses a Long (and if it doesn't should also be fixed :).

-Ted

On Feb 29, 2012, at 1:40 PM, A.J. Brown wrote:

It appears that the expire parameter is expected to be an Integer. Since the expire time is in milliseconds, it should be expected to be a Long in order to support bigger expire times.

This breaks (expire in 60 days):
@memoize( key="autocomplete:#{query}", expire='5184000000' )

with a NumberFormatException

This works fine
@memoize( key="autocomplete:#{query}", expire='5184000' )

It looks like the problem is in line 62 of MemoizeASTTransformation.groovy:
argumentListExpression.addExpression(makeConstantExpression(Integer.parseInt(memoizeProperties.get(EXPIRE).toString())))

I will attempt a fix and open a pull request.


Reply to this email directly or view it on GitHub:
#5

@ajbrown
Copy link
Author

ajbrown commented Feb 29, 2012

Actually upon further investigation, this isn't an issue. The issue is with the documentation, which states the expire time should be in miliseconds. In fact, it should be in seconds.

@memoize( key="autocomplete:#{query}", expire='5184000' )

results in:

"SETEX" "autocomplete:Dayto" "5184000"

And according to the Redis docs, the second parameter is in seconds.

Under the hood, Jedis excepts an int as the setex() parameter anyway, so the plugin should probably do the same.

@ajbrown ajbrown closed this as completed Feb 29, 2012
@ajbrown ajbrown reopened this Feb 29, 2012
@ajbrown
Copy link
Author

ajbrown commented Feb 29, 2012

Didn't mean to close it since it should probably stay open until the documentation is updated :-)

@tednaleid
Copy link
Contributor

Thanks for digging in to it, I updated the docs to reflect that it's actually seconds, not milliseconds.

-Ted

On Feb 29, 2012, at 1:57 PM, A.J. Brown wrote:

Didn't mean to close it since it should probably stay open until the documentation is updated :-)


Reply to this email directly or view it on GitHub:
#5 (comment)

@ajbrown ajbrown closed this as completed Feb 29, 2012
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

2 participants