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

issue #72, Exipration stuff #125

Closed
wants to merge 12 commits into from
Closed

issue #72, Exipration stuff #125

wants to merge 12 commits into from

Conversation

timeck
Copy link
Contributor

@timeck timeck commented Oct 28, 2014

Plenty of questionable things in here:

  • The interface of org.ehcache.expiry.Expiry
  • The way Expiry gets into a Cache and then onto the Store, as explicit methods on the config objects
  • The way the TimeSource gets into OnHeapStore (no idea if I used the service config concept correctly)
    • see org.ehcache.internal.store.OnHeapStore.Provider

@terracotta-org
Copy link
Contributor

Test PASSed.


switch (timeUnit) {
case MICROSECONDS:
case NANOSECONDS: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only am I not a fan of the restriction (and wasn't in 107 neither), but also why would 1,000,000 TimeUnit.NANOSECONDS not be acceptable and would have to be represented in TimeUnit.MILLISECONDS ?
Long story short, why do we limit this here. Why wouldn't it the Store 's concern to decide how it deals with too small values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I did without thinking too much about it, and obviously I've let 107 infect me.

To be sure, I think you're making two points:
(1) why disallow specified a duration that is effectively equal or greater than 1 ms, even if it expressed in a smaller time unit
(2) Why limit the durations at all, let every Store decide if a duration is too small for it

They're both reasonable. I have hesitation with (2) though. In reality we don't know of a Store that could provide less than millisecond precision (I don't at least). It also seems complicated to decide how to log when a Duration too small is observed (since it happens for most every operation).

We can always remove the limitation later?

I don't feel too strongly about this to be honest. I'm definitely lazy in not wanting to deal with in multiple Store impls though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's it... but true that! Rather remove the limitation later than the other way around. Again, with 107 in mind, this passes all test!

Now, I still think that point 1 is relevant... and if we convert to "smallest unit" supported (i.e. MILLISECONDS), it would always resolve... including to possibly 0. Anyways we can worry about this later. If you decide to leave it as so, could you just file an issue wrt that?

@terracotta-org
Copy link
Contributor

Test PASSed.

@terracotta-org
Copy link
Contributor

Test FAILed.

@terracotta-org
Copy link
Contributor

Test PASSed.

2 similar comments
@terracotta-org
Copy link
Contributor

Test PASSed.

@terracotta-org
Copy link
Contributor

Test PASSed.

checkKey(key);
checkValue(value);

final AtomicReference<OnHeapValueHolder<V>> returnValue = new AtomicReference<OnHeapValueHolder<V>>(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is subjective and mostly about stylistic: but you could make that BiFunction below side-effect free by building the new ValueHolder prior to invoking it. Have the method "close over" it (as well as the now, which I initially didn't like, but since it's used in a Map.compute, it actually lowers the contention on the key, while widening the timing "error", but the former is probably desirable over the latter... so I think it's actually desirable this way).

Anyways, having the method side-effect free is probably more functional... or so they say.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered creating the new ValueHolder outside the function as well. My reasoning for doing it inside was so that the Expiry.getExpiryForCreation() would only ever be called if something was indeed being added. Creating the potential new value holder up front makes the call on the Expiry but that might not end up in the store.

I'm happy to change things to minimize the work inside the function if desired, but I did have my reason for doing it the way it is

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Yeah... that's a good reason indeed. Should have looked into the newValueHolder method indeed. Given this is only about "style", I'd keep it as you implemented this indeed. Probably "least surprise" to the end-user!

@terracotta-org
Copy link
Contributor

Test PASSed.

@timeck timeck changed the title For review comments only - issue #72, Exipration stuff issue #72, Exipration stuff Nov 3, 2014
@terracotta-org
Copy link
Contributor

Test PASSed.

1 similar comment
@terracotta-org
Copy link
Contributor

Test PASSed.

// }
//
// return new TimeToLiveAndTimeToIdleExpiry(timeToLive, timeToIdle);
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that a leftover? Or something that might be needed in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda left it in there commented since it might needed in the future, but given that I usually request others to remove commented code I should do the same

@hhuynh
Copy link
Contributor

hhuynh commented Nov 4, 2014

Not much to add from me

@ljacomet
Copy link
Member

ljacomet commented Nov 5, 2014

Before merging this, wait for timeck/ehcache3@c16c51b to be added to it

Conflicts:
	core/src/main/java/org/ehcache/spi/cache/Store.java
@terracotta-org
Copy link
Contributor

Test FAILed.

2 similar comments
@terracotta-org
Copy link
Contributor

Test FAILed.

@terracotta-org
Copy link
Contributor

Test FAILed.

@timeck
Copy link
Contributor Author

timeck commented Nov 5, 2014

test this please

@terracotta-org
Copy link
Contributor

Test PASSed.

@terracotta-org
Copy link
Contributor

Test FAILed.

@timeck
Copy link
Contributor Author

timeck commented Nov 5, 2014

test this please

@terracotta-org
Copy link
Contributor

Test PASSed.

@ljacomet
Copy link
Member

ljacomet commented Nov 6, 2014

Looks good to me know - not merging just yet to make sure other reviewers get a final look.

@timeck timeck closed this Nov 10, 2014
@timeck timeck deleted the issue-72 branch November 10, 2014 02:28
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

6 participants