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

Fix cache TTL bug #252

Merged
merged 1 commit into from Dec 19, 2013
Merged

Conversation

caiiiycuk
Copy link
Contributor

LruCache works incorrect. Methods like putSecond, putHour, putDay never works:

if (expireSec.toLong * 1000 < nowMs) None else Some(value)

expireSec is just seconds without system time offset, for example:
putSecond("key", "value", 1) - expireSec == 1, 1000 always < System.currentTimeMillis().

I try to fix it in this pull request.

  1. There are bug in docs:
    http://ngocdaothanh.github.io/xitrum/guide/cache.html?highlight=cache#cache-object
Without an explicit TTL (time to live):

    put(key, value)

Without an explicit TTL: <<!!!! HERE (should be With an explicit TTL:)

    putSecond(key, value, seconds)
    putMinute(key, value, minutes)
    putHour(key, value, hours)
    putDay(key, value, days)
  1. I add logback-test.xml but it does not works, no any logs are showing. I dont know why, it should works.

@ngocdaothanh
Copy link
Member

Thanks a lot!

But can you change:

LocalLruCache[Any, (Long, Any)](maxElems)

back to:

LocalLruCache[Any, (Int, Any)](maxElems)

It's because:

  • We don't need millisecond precision, second is OK.
  • Using Int saves some space. Int is 4 bytes while Long is 8 bytes.

@ngocdaothanh
Copy link
Member

I add logback-test.xml but it does not works, no any logs are showing.

Try changing <root level="ERROR"> to <root level="DEBUG">, ex:
https://github.com/ngocdaothanh/xitrum-new/blob/master/config/logback.xml

@caiiiycuk
Copy link
Contributor Author

Fixed.

About logger, log level DEBUG also does not work...

@ngocdaothanh
Copy link
Member

Thanks!

ngocdaothanh added a commit to xitrum-framework/xitrum-doc that referenced this pull request Dec 19, 2013
@ngocdaothanh
Copy link
Member

I've fixed and published the Xitrum Guide. It should be online soon.

@ngocdaothanh ngocdaothanh reopened this Dec 19, 2013
ngocdaothanh added a commit that referenced this pull request Dec 19, 2013
@ngocdaothanh ngocdaothanh merged commit 015dd01 into xitrum-framework:master Dec 19, 2013
@ngocdaothanh
Copy link
Member

About the log, what log do you want to see?

I don't see any call in your tests that outputs log. So of course no log will be output.

ngocdaothanh pushed a commit that referenced this pull request Dec 19, 2013
@ngocdaothanh
Copy link
Member

I guess you want to see log like route collection log when normal Xitrum app is started? That log is only output when xitrum.Server is started.

@ngocdaothanh
Copy link
Member

I will release Xitrum 2.14 in a few minutes.

@caiiiycuk
Copy link
Contributor Author

I guess you want to see log like route collection log when normal Xitrum app is started? That log is only output when xitrum.Server is started.

When i delete xitrum.conf from test/resources and run sbt test, then error about missing xitrum key does not shown (log.e() called).

It is normal?

@ngocdaothanh
Copy link
Member

It is normal?

Yes, because the current tests still haven't caused xitrum.conf to be loaded. Try adding xitrum.Server.start() to one of the tests, you will see that it will not pass.

However, because previously an implementation of SLF4J is not in the classpath, even when there's error log, you will not see it because without an implementation, all error logs will be ingored.

I've just added Logback to test environment:
f49501a

Now if you delete xitrum.conf and add xitrum.Server.start() to one of the tests, you will see this error:

[ERROR] Could not load config/xitrum.conf

@ngocdaothanh
Copy link
Member

FYI, I've just added "Xitrum 3" branch:
https://github.com/ngocdaothanh/xitrum/tree/3

The purpose is to update Netty from 3.x to 4.x. I think Xitrum 3 which uses Netty 4.x can be released in January.

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

2 participants