repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
EdwardRaff/JSAT | JSAT/src/jsat/distributions/kernels/RBFKernel.java | RBFKernel.setSigma | public void setSigma(double sigma)
{
if(sigma <= 0)
throw new IllegalArgumentException("Sigma must be a positive constant, not " + sigma);
this.sigma = sigma;
this.sigmaSqrd2Inv = 0.5/(sigma*sigma);
} | java | public void setSigma(double sigma)
{
if(sigma <= 0)
throw new IllegalArgumentException("Sigma must be a positive constant, not " + sigma);
this.sigma = sigma;
this.sigmaSqrd2Inv = 0.5/(sigma*sigma);
} | [
"public",
"void",
"setSigma",
"(",
"double",
"sigma",
")",
"{",
"if",
"(",
"sigma",
"<=",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Sigma must be a positive constant, not \"",
"+",
"sigma",
")",
";",
"this",
".",
"sigma",
"=",
"sigma",
";",... | Sets the sigma parameter, which must be a positive value
@param sigma the sigma value | [
"Sets",
"the",
"sigma",
"parameter",
"which",
"must",
"be",
"a",
"positive",
"value"
] | 0ff53b7b39684b2379cc1da522f5b3a954b15cfb | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/distributions/kernels/RBFKernel.java#L79-L85 | train |
EdwardRaff/JSAT | JSAT/src/jsat/classifiers/boosting/WaggingNormal.java | WaggingNormal.setMean | public void setMean(double mean)
{
if(Double.isInfinite(mean) || Double.isNaN(mean))
throw new ArithmeticException("Mean must be a real number, not " + mean);
((Normal)getDistribution()).setMean(mean);
} | java | public void setMean(double mean)
{
if(Double.isInfinite(mean) || Double.isNaN(mean))
throw new ArithmeticException("Mean must be a real number, not " + mean);
((Normal)getDistribution()).setMean(mean);
} | [
"public",
"void",
"setMean",
"(",
"double",
"mean",
")",
"{",
"if",
"(",
"Double",
".",
"isInfinite",
"(",
"mean",
")",
"||",
"Double",
".",
"isNaN",
"(",
"mean",
")",
")",
"throw",
"new",
"ArithmeticException",
"(",
"\"Mean must be a real number, not \"",
"... | Sets the mean value used for the normal distribution
@param mean the new mean value | [
"Sets",
"the",
"mean",
"value",
"used",
"for",
"the",
"normal",
"distribution"
] | 0ff53b7b39684b2379cc1da522f5b3a954b15cfb | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/boosting/WaggingNormal.java#L66-L71 | train |
EdwardRaff/JSAT | JSAT/src/jsat/classifiers/boosting/WaggingNormal.java | WaggingNormal.setStandardDeviations | public void setStandardDeviations(double devs)
{
if(devs <= 0 || Double.isInfinite(devs) || Double.isNaN(devs))
throw new ArithmeticException("The stnd devs must be a positive value");
((Normal)getDistribution()).setStndDev(devs);
} | java | public void setStandardDeviations(double devs)
{
if(devs <= 0 || Double.isInfinite(devs) || Double.isNaN(devs))
throw new ArithmeticException("The stnd devs must be a positive value");
((Normal)getDistribution()).setStndDev(devs);
} | [
"public",
"void",
"setStandardDeviations",
"(",
"double",
"devs",
")",
"{",
"if",
"(",
"devs",
"<=",
"0",
"||",
"Double",
".",
"isInfinite",
"(",
"devs",
")",
"||",
"Double",
".",
"isNaN",
"(",
"devs",
")",
")",
"throw",
"new",
"ArithmeticException",
"("... | Sets the standard deviations used for the normal distribution
@param devs the standard deviations to set | [
"Sets",
"the",
"standard",
"deviations",
"used",
"for",
"the",
"normal",
"distribution"
] | 0ff53b7b39684b2379cc1da522f5b3a954b15cfb | https://github.com/EdwardRaff/JSAT/blob/0ff53b7b39684b2379cc1da522f5b3a954b15cfb/JSAT/src/jsat/classifiers/boosting/WaggingNormal.java#L86-L91 | train |
JodaOrg/joda-money | src/main/java/org/joda/money/DefaultCurrencyUnitDataProvider.java | DefaultCurrencyUnitDataProvider.registerCurrencies | @Override
protected void registerCurrencies() throws Exception {
parseCurrencies(loadFromFile("/org/joda/money/CurrencyData.csv"));
parseCountries(loadFromFile("/org/joda/money/CountryData.csv"));
parseCurrencies(loadFromFiles("META-INF/org/joda/money/CurrencyDataExtension.csv"));
... | java | @Override
protected void registerCurrencies() throws Exception {
parseCurrencies(loadFromFile("/org/joda/money/CurrencyData.csv"));
parseCountries(loadFromFile("/org/joda/money/CountryData.csv"));
parseCurrencies(loadFromFiles("META-INF/org/joda/money/CurrencyDataExtension.csv"));
... | [
"@",
"Override",
"protected",
"void",
"registerCurrencies",
"(",
")",
"throws",
"Exception",
"{",
"parseCurrencies",
"(",
"loadFromFile",
"(",
"\"/org/joda/money/CurrencyData.csv\"",
")",
")",
";",
"parseCountries",
"(",
"loadFromFile",
"(",
"\"/org/joda/money/CountryData... | Registers all the currencies known by this provider.
@throws Exception if an error occurs | [
"Registers",
"all",
"the",
"currencies",
"known",
"by",
"this",
"provider",
"."
] | e1f2de75aa36610a695358696c8a88a18ca66cde | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/DefaultCurrencyUnitDataProvider.java#L54-L60 | train |
JodaOrg/joda-money | src/main/java/org/joda/money/DefaultCurrencyUnitDataProvider.java | DefaultCurrencyUnitDataProvider.parseCurrencies | private void parseCurrencies(List<String> content) throws Exception {
for (String line : content) {
Matcher matcher = CURRENCY_REGEX_LINE.matcher(line);
if (matcher.matches()) {
String currencyCode = matcher.group(1);
int numericCode = Integer.parseIn... | java | private void parseCurrencies(List<String> content) throws Exception {
for (String line : content) {
Matcher matcher = CURRENCY_REGEX_LINE.matcher(line);
if (matcher.matches()) {
String currencyCode = matcher.group(1);
int numericCode = Integer.parseIn... | [
"private",
"void",
"parseCurrencies",
"(",
"List",
"<",
"String",
">",
"content",
")",
"throws",
"Exception",
"{",
"for",
"(",
"String",
"line",
":",
"content",
")",
"{",
"Matcher",
"matcher",
"=",
"CURRENCY_REGEX_LINE",
".",
"matcher",
"(",
"line",
")",
"... | parse the currencies | [
"parse",
"the",
"currencies"
] | e1f2de75aa36610a695358696c8a88a18ca66cde | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/DefaultCurrencyUnitDataProvider.java#L96-L106 | train |
JodaOrg/joda-money | src/main/java/org/joda/money/DefaultCurrencyUnitDataProvider.java | DefaultCurrencyUnitDataProvider.parseCountries | private void parseCountries(List<String> content) throws Exception {
for (String line : content) {
Matcher matcher = COUNTRY_REGEX_LINE.matcher(line);
if (matcher.matches()) {
String countryCode = matcher.group(1);
String currencyCode = matcher.group(... | java | private void parseCountries(List<String> content) throws Exception {
for (String line : content) {
Matcher matcher = COUNTRY_REGEX_LINE.matcher(line);
if (matcher.matches()) {
String countryCode = matcher.group(1);
String currencyCode = matcher.group(... | [
"private",
"void",
"parseCountries",
"(",
"List",
"<",
"String",
">",
"content",
")",
"throws",
"Exception",
"{",
"for",
"(",
"String",
"line",
":",
"content",
")",
"{",
"Matcher",
"matcher",
"=",
"COUNTRY_REGEX_LINE",
".",
"matcher",
"(",
"line",
")",
";"... | parse the countries | [
"parse",
"the",
"countries"
] | e1f2de75aa36610a695358696c8a88a18ca66cde | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/DefaultCurrencyUnitDataProvider.java#L109-L118 | train |
JodaOrg/joda-money | src/main/java/org/joda/money/format/MoneyAmountStyle.java | MoneyAmountStyle.withGroupingSize | public MoneyAmountStyle withGroupingSize(Integer groupingSize) {
int sizeVal = (groupingSize == null ? -1 : groupingSize);
if (groupingSize != null && sizeVal <= 0) {
throw new IllegalArgumentException("Grouping size must be greater than zero");
}
if (sizeVal == this.gro... | java | public MoneyAmountStyle withGroupingSize(Integer groupingSize) {
int sizeVal = (groupingSize == null ? -1 : groupingSize);
if (groupingSize != null && sizeVal <= 0) {
throw new IllegalArgumentException("Grouping size must be greater than zero");
}
if (sizeVal == this.gro... | [
"public",
"MoneyAmountStyle",
"withGroupingSize",
"(",
"Integer",
"groupingSize",
")",
"{",
"int",
"sizeVal",
"=",
"(",
"groupingSize",
"==",
"null",
"?",
"-",
"1",
":",
"groupingSize",
")",
";",
"if",
"(",
"groupingSize",
"!=",
"null",
"&&",
"sizeVal",
"<="... | Returns a copy of this style with the specified grouping size.
@param groupingSize the size of each group, such as 3 for thousands,
not zero or negative, null if to be determined by locale
@return the new instance for chaining, never null
@throws IllegalArgumentException if the grouping size is zero or less | [
"Returns",
"a",
"copy",
"of",
"this",
"style",
"with",
"the",
"specified",
"grouping",
"size",
"."
] | e1f2de75aa36610a695358696c8a88a18ca66cde | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/format/MoneyAmountStyle.java#L469-L482 | train |
JodaOrg/joda-money | src/main/java/org/joda/money/format/MoneyAmountStyle.java | MoneyAmountStyle.withExtendedGroupingSize | public MoneyAmountStyle withExtendedGroupingSize(Integer extendedGroupingSize) {
int sizeVal = (extendedGroupingSize == null ? -1 : extendedGroupingSize);
if (extendedGroupingSize != null && sizeVal < 0) {
throw new IllegalArgumentException("Extended grouping size must not be negative");
... | java | public MoneyAmountStyle withExtendedGroupingSize(Integer extendedGroupingSize) {
int sizeVal = (extendedGroupingSize == null ? -1 : extendedGroupingSize);
if (extendedGroupingSize != null && sizeVal < 0) {
throw new IllegalArgumentException("Extended grouping size must not be negative");
... | [
"public",
"MoneyAmountStyle",
"withExtendedGroupingSize",
"(",
"Integer",
"extendedGroupingSize",
")",
"{",
"int",
"sizeVal",
"=",
"(",
"extendedGroupingSize",
"==",
"null",
"?",
"-",
"1",
":",
"extendedGroupingSize",
")",
";",
"if",
"(",
"extendedGroupingSize",
"!=... | Returns a copy of this style with the specified extended grouping size.
@param extendedGroupingSize the size of each group, such as 3 for thousands,
not zero or negative, null if to be determined by locale
@return the new instance for chaining, never null
@throws IllegalArgumentException if the grouping size is zero ... | [
"Returns",
"a",
"copy",
"of",
"this",
"style",
"with",
"the",
"specified",
"extended",
"grouping",
"size",
"."
] | e1f2de75aa36610a695358696c8a88a18ca66cde | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/format/MoneyAmountStyle.java#L507-L520 | train |
JodaOrg/joda-money | src/main/java/org/joda/money/format/MoneyAmountStyle.java | MoneyAmountStyle.withGroupingStyle | public MoneyAmountStyle withGroupingStyle(GroupingStyle groupingStyle) {
MoneyFormatter.checkNotNull(groupingStyle, "groupingStyle");
if (this.groupingStyle == groupingStyle) {
return this;
}
return new MoneyAmountStyle(
zeroCharacter,
p... | java | public MoneyAmountStyle withGroupingStyle(GroupingStyle groupingStyle) {
MoneyFormatter.checkNotNull(groupingStyle, "groupingStyle");
if (this.groupingStyle == groupingStyle) {
return this;
}
return new MoneyAmountStyle(
zeroCharacter,
p... | [
"public",
"MoneyAmountStyle",
"withGroupingStyle",
"(",
"GroupingStyle",
"groupingStyle",
")",
"{",
"MoneyFormatter",
".",
"checkNotNull",
"(",
"groupingStyle",
",",
"\"groupingStyle\"",
")",
";",
"if",
"(",
"this",
".",
"groupingStyle",
"==",
"groupingStyle",
")",
... | Returns a copy of this style with the specified grouping setting.
@param groupingStyle the grouping style, not null
@return the new instance for chaining, never null | [
"Returns",
"a",
"copy",
"of",
"this",
"style",
"with",
"the",
"specified",
"grouping",
"setting",
"."
] | e1f2de75aa36610a695358696c8a88a18ca66cde | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/format/MoneyAmountStyle.java#L538-L548 | train |
JodaOrg/joda-money | src/main/java/org/joda/money/format/MoneyAmountStyle.java | MoneyAmountStyle.withForcedDecimalPoint | public MoneyAmountStyle withForcedDecimalPoint(boolean forceDecimalPoint) {
if (this.forceDecimalPoint == forceDecimalPoint) {
return this;
}
return new MoneyAmountStyle(
zeroCharacter,
positiveCharacter, negativeCharacter,
decim... | java | public MoneyAmountStyle withForcedDecimalPoint(boolean forceDecimalPoint) {
if (this.forceDecimalPoint == forceDecimalPoint) {
return this;
}
return new MoneyAmountStyle(
zeroCharacter,
positiveCharacter, negativeCharacter,
decim... | [
"public",
"MoneyAmountStyle",
"withForcedDecimalPoint",
"(",
"boolean",
"forceDecimalPoint",
")",
"{",
"if",
"(",
"this",
".",
"forceDecimalPoint",
"==",
"forceDecimalPoint",
")",
"{",
"return",
"this",
";",
"}",
"return",
"new",
"MoneyAmountStyle",
"(",
"zeroCharac... | Returns a copy of this style with the specified decimal point setting.
@param forceDecimalPoint true to force the use of the decimal point, false to use it if required
@return the new instance for chaining, never null | [
"Returns",
"a",
"copy",
"of",
"this",
"style",
"with",
"the",
"specified",
"decimal",
"point",
"setting",
"."
] | e1f2de75aa36610a695358696c8a88a18ca66cde | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/format/MoneyAmountStyle.java#L566-L575 | train |
JodaOrg/joda-money | src/main/java/org/joda/money/BigMoney.java | BigMoney.checkCurrencyEqual | private BigMoney checkCurrencyEqual(BigMoneyProvider moneyProvider) {
BigMoney money = of(moneyProvider);
if (isSameCurrency(money) == false) {
throw new CurrencyMismatchException(getCurrencyUnit(), money.getCurrencyUnit());
}
return money;
} | java | private BigMoney checkCurrencyEqual(BigMoneyProvider moneyProvider) {
BigMoney money = of(moneyProvider);
if (isSameCurrency(money) == false) {
throw new CurrencyMismatchException(getCurrencyUnit(), money.getCurrencyUnit());
}
return money;
} | [
"private",
"BigMoney",
"checkCurrencyEqual",
"(",
"BigMoneyProvider",
"moneyProvider",
")",
"{",
"BigMoney",
"money",
"=",
"of",
"(",
"moneyProvider",
")",
";",
"if",
"(",
"isSameCurrency",
"(",
"money",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"CurrencyM... | Validates that the currency of this money and the specified money match.
@param moneyProvider the money to check, not null
@throws CurrencyMismatchException if the currencies differ | [
"Validates",
"that",
"the",
"currency",
"of",
"this",
"money",
"and",
"the",
"specified",
"money",
"match",
"."
] | e1f2de75aa36610a695358696c8a88a18ca66cde | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/BigMoney.java#L803-L809 | train |
JodaOrg/joda-money | src/main/java/org/joda/money/BigMoney.java | BigMoney.compareTo | @Override
public int compareTo(BigMoneyProvider other) {
BigMoney otherMoney = of(other);
if (currency.equals(otherMoney.currency) == false) {
throw new CurrencyMismatchException(getCurrencyUnit(), otherMoney.getCurrencyUnit());
}
return amount.compareTo(otherMoney.... | java | @Override
public int compareTo(BigMoneyProvider other) {
BigMoney otherMoney = of(other);
if (currency.equals(otherMoney.currency) == false) {
throw new CurrencyMismatchException(getCurrencyUnit(), otherMoney.getCurrencyUnit());
}
return amount.compareTo(otherMoney.... | [
"@",
"Override",
"public",
"int",
"compareTo",
"(",
"BigMoneyProvider",
"other",
")",
"{",
"BigMoney",
"otherMoney",
"=",
"of",
"(",
"other",
")",
";",
"if",
"(",
"currency",
".",
"equals",
"(",
"otherMoney",
".",
"currency",
")",
"==",
"false",
")",
"{"... | Compares this monetary value to another.
The compared values must be in the same currency.
@param other the other monetary value, not null
@return -1 if this is less than , 0 if equal, 1 if greater than
@throws CurrencyMismatchException if the currencies differ | [
"Compares",
"this",
"monetary",
"value",
"to",
"another",
".",
"The",
"compared",
"values",
"must",
"be",
"in",
"the",
"same",
"currency",
"."
] | e1f2de75aa36610a695358696c8a88a18ca66cde | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/BigMoney.java#L1603-L1610 | train |
JodaOrg/joda-money | src/main/java/org/joda/money/format/MoneyParseContext.java | MoneyParseContext.mergeChild | void mergeChild(MoneyParseContext child) {
setLocale(child.getLocale());
setText(child.getText());
setIndex(child.getIndex());
setErrorIndex(child.getErrorIndex());
setCurrency(child.getCurrency());
setAmount(child.getAmount());
} | java | void mergeChild(MoneyParseContext child) {
setLocale(child.getLocale());
setText(child.getText());
setIndex(child.getIndex());
setErrorIndex(child.getErrorIndex());
setCurrency(child.getCurrency());
setAmount(child.getAmount());
} | [
"void",
"mergeChild",
"(",
"MoneyParseContext",
"child",
")",
"{",
"setLocale",
"(",
"child",
".",
"getLocale",
"(",
")",
")",
";",
"setText",
"(",
"child",
".",
"getText",
"(",
")",
")",
";",
"setIndex",
"(",
"child",
".",
"getIndex",
"(",
")",
")",
... | Merges the child context back into this instance.
@param child the child context, not null | [
"Merges",
"the",
"child",
"context",
"back",
"into",
"this",
"instance",
"."
] | e1f2de75aa36610a695358696c8a88a18ca66cde | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/format/MoneyParseContext.java#L276-L283 | train |
JodaOrg/joda-money | src/main/java/org/joda/money/format/MoneyParseContext.java | MoneyParseContext.toParsePosition | public ParsePosition toParsePosition() {
ParsePosition pp = new ParsePosition(textIndex);
pp.setErrorIndex(textErrorIndex);
return pp;
} | java | public ParsePosition toParsePosition() {
ParsePosition pp = new ParsePosition(textIndex);
pp.setErrorIndex(textErrorIndex);
return pp;
} | [
"public",
"ParsePosition",
"toParsePosition",
"(",
")",
"{",
"ParsePosition",
"pp",
"=",
"new",
"ParsePosition",
"(",
"textIndex",
")",
";",
"pp",
".",
"setErrorIndex",
"(",
"textErrorIndex",
")",
";",
"return",
"pp",
";",
"}"
] | Converts the indexes to a parse position.
@return the parse position, never null | [
"Converts",
"the",
"indexes",
"to",
"a",
"parse",
"position",
"."
] | e1f2de75aa36610a695358696c8a88a18ca66cde | https://github.com/JodaOrg/joda-money/blob/e1f2de75aa36610a695358696c8a88a18ca66cde/src/main/java/org/joda/money/format/MoneyParseContext.java#L291-L295 | train |
cache2k/cache2k | cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheAdapter.java | JCacheAdapter.iterator | @Override
public Iterator<Entry<K,V>> iterator() {
checkClosed();
final Iterator<K> _keyIterator = cache.keys().iterator();
return new Iterator<Entry<K, V>>() {
CacheEntry<K, V> entry;
@Override
public boolean hasNext() {
while(_keyIterator.hasNext()) {
entry = cache.... | java | @Override
public Iterator<Entry<K,V>> iterator() {
checkClosed();
final Iterator<K> _keyIterator = cache.keys().iterator();
return new Iterator<Entry<K, V>>() {
CacheEntry<K, V> entry;
@Override
public boolean hasNext() {
while(_keyIterator.hasNext()) {
entry = cache.... | [
"@",
"Override",
"public",
"Iterator",
"<",
"Entry",
"<",
"K",
",",
"V",
">",
">",
"iterator",
"(",
")",
"{",
"checkClosed",
"(",
")",
";",
"final",
"Iterator",
"<",
"K",
">",
"_keyIterator",
"=",
"cache",
".",
"keys",
"(",
")",
".",
"iterator",
"(... | Iterate with the help of cache2k key iterator. | [
"Iterate",
"with",
"the",
"help",
"of",
"cache2k",
"key",
"iterator",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheAdapter.java#L451-L506 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/CacheManager.java | CacheManager.getInstance | public static CacheManager getInstance() {
ClassLoader _defaultClassLoader = PROVIDER.getDefaultClassLoader();
return PROVIDER.getManager(_defaultClassLoader, PROVIDER.getDefaultManagerName(_defaultClassLoader));
} | java | public static CacheManager getInstance() {
ClassLoader _defaultClassLoader = PROVIDER.getDefaultClassLoader();
return PROVIDER.getManager(_defaultClassLoader, PROVIDER.getDefaultManagerName(_defaultClassLoader));
} | [
"public",
"static",
"CacheManager",
"getInstance",
"(",
")",
"{",
"ClassLoader",
"_defaultClassLoader",
"=",
"PROVIDER",
".",
"getDefaultClassLoader",
"(",
")",
";",
"return",
"PROVIDER",
".",
"getManager",
"(",
"_defaultClassLoader",
",",
"PROVIDER",
".",
"getDefau... | Get the default cache manager for the default class loader. The default class loader
is the class loader used to load the cache2k implementation classes.
<p>The name of default cache manager is {@code "default"}.
This may be changed, by {@link #setDefaultName(String)}. | [
"Get",
"the",
"default",
"cache",
"manager",
"for",
"the",
"default",
"class",
"loader",
".",
"The",
"default",
"class",
"loader",
"is",
"the",
"class",
"loader",
"used",
"to",
"load",
"the",
"cache2k",
"implementation",
"classes",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/CacheManager.java#L87-L90 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/CacheManager.java | CacheManager.getInstance | public static CacheManager getInstance(ClassLoader cl) {
return PROVIDER.getManager(cl, PROVIDER.getDefaultManagerName(cl));
} | java | public static CacheManager getInstance(ClassLoader cl) {
return PROVIDER.getManager(cl, PROVIDER.getDefaultManagerName(cl));
} | [
"public",
"static",
"CacheManager",
"getInstance",
"(",
"ClassLoader",
"cl",
")",
"{",
"return",
"PROVIDER",
".",
"getManager",
"(",
"cl",
",",
"PROVIDER",
".",
"getDefaultManagerName",
"(",
"cl",
")",
")",
";",
"}"
] | Get the default cache manager for the specified class loader. | [
"Get",
"the",
"default",
"cache",
"manager",
"for",
"the",
"specified",
"class",
"loader",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/CacheManager.java#L95-L97 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/CacheManager.java | CacheManager.getInstance | public static CacheManager getInstance(ClassLoader cl, String managerName) {
return PROVIDER.getManager(cl, managerName);
} | java | public static CacheManager getInstance(ClassLoader cl, String managerName) {
return PROVIDER.getManager(cl, managerName);
} | [
"public",
"static",
"CacheManager",
"getInstance",
"(",
"ClassLoader",
"cl",
",",
"String",
"managerName",
")",
"{",
"return",
"PROVIDER",
".",
"getManager",
"(",
"cl",
",",
"managerName",
")",
";",
"}"
] | Retrieve a cache manager with the specified name using the specified classloader.
If not existing, a manager with that name is created. Different cache managers are
created for different class loaders. Manager names should be unique within one VM instance.
<p>The allowed characters in a manager name are identical to t... | [
"Retrieve",
"a",
"cache",
"manager",
"with",
"the",
"specified",
"name",
"using",
"the",
"specified",
"classloader",
".",
"If",
"not",
"existing",
"a",
"manager",
"with",
"that",
"name",
"is",
"created",
".",
"Different",
"cache",
"managers",
"are",
"created",... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/CacheManager.java#L123-L125 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.of | public static <K,T> Cache2kBuilder<K,T> of(Class<K> _keyType, Class<T> _valueType) {
return new Cache2kBuilder<K, T>(CacheTypeCapture.of(_keyType), CacheTypeCapture.of(_valueType));
} | java | public static <K,T> Cache2kBuilder<K,T> of(Class<K> _keyType, Class<T> _valueType) {
return new Cache2kBuilder<K, T>(CacheTypeCapture.of(_keyType), CacheTypeCapture.of(_valueType));
} | [
"public",
"static",
"<",
"K",
",",
"T",
">",
"Cache2kBuilder",
"<",
"K",
",",
"T",
">",
"of",
"(",
"Class",
"<",
"K",
">",
"_keyType",
",",
"Class",
"<",
"T",
">",
"_valueType",
")",
"{",
"return",
"new",
"Cache2kBuilder",
"<",
"K",
",",
"T",
">"... | Create a new cache builder for key and value types of classes with no generic parameters.
@see #keyType(Class)
@see #valueType(Class) | [
"Create",
"a",
"new",
"cache",
"builder",
"for",
"key",
"and",
"value",
"types",
"of",
"classes",
"with",
"no",
"generic",
"parameters",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L99-L101 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.of | public static <K,T> Cache2kBuilder<K, T> of(Cache2kConfiguration<K, T> c) {
Cache2kBuilder<K,T> cb = new Cache2kBuilder<K, T>(c);
return cb;
} | java | public static <K,T> Cache2kBuilder<K, T> of(Cache2kConfiguration<K, T> c) {
Cache2kBuilder<K,T> cb = new Cache2kBuilder<K, T>(c);
return cb;
} | [
"public",
"static",
"<",
"K",
",",
"T",
">",
"Cache2kBuilder",
"<",
"K",
",",
"T",
">",
"of",
"(",
"Cache2kConfiguration",
"<",
"K",
",",
"T",
">",
"c",
")",
"{",
"Cache2kBuilder",
"<",
"K",
",",
"T",
">",
"cb",
"=",
"new",
"Cache2kBuilder",
"<",
... | Create a builder from the configuration. | [
"Create",
"a",
"builder",
"from",
"the",
"configuration",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L106-L109 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.manager | public final Cache2kBuilder<K, V> manager(CacheManager manager) {
if (this.manager != null) {
throw new IllegalStateException("manager() must be first operation on builder.");
}
this.manager = manager;
return this;
} | java | public final Cache2kBuilder<K, V> manager(CacheManager manager) {
if (this.manager != null) {
throw new IllegalStateException("manager() must be first operation on builder.");
}
this.manager = manager;
return this;
} | [
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"manager",
"(",
"CacheManager",
"manager",
")",
"{",
"if",
"(",
"this",
".",
"manager",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"manager() must be first operation on bu... | The manager, the created cache will belong to. If this is set, it must be the
first method called.
@param manager The manager the created cache should belong to,
or {@code null} if the default cache manager should be used
@throws IllegalStateException if the manager is not provided immediately after the builder is cre... | [
"The",
"manager",
"the",
"created",
"cache",
"will",
"belong",
"to",
".",
"If",
"this",
"is",
"set",
"it",
"must",
"be",
"the",
"first",
"method",
"called",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L182-L188 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.valueType | @SuppressWarnings("unchecked")
public final <T2> Cache2kBuilder<K, T2> valueType(CacheType<T2> t) {
Cache2kBuilder<K, T2> me = (Cache2kBuilder<K, T2>) this;
me.config().setValueType(t);
return me;
} | java | @SuppressWarnings("unchecked")
public final <T2> Cache2kBuilder<K, T2> valueType(CacheType<T2> t) {
Cache2kBuilder<K, T2> me = (Cache2kBuilder<K, T2>) this;
me.config().setValueType(t);
return me;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"<",
"T2",
">",
"Cache2kBuilder",
"<",
"K",
",",
"T2",
">",
"valueType",
"(",
"CacheType",
"<",
"T2",
">",
"t",
")",
"{",
"Cache2kBuilder",
"<",
"K",
",",
"T2",
">",
"me",
"=",
"(... | Sets the value type to use. Arrays are not supported.
@throws IllegalArgumentException in case the type is illegal
@see CacheType for a general discussion on types | [
"Sets",
"the",
"value",
"type",
"to",
"use",
".",
"Arrays",
"are",
"not",
"supported",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L237-L242 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.name | public final Cache2kBuilder<K, V> name(Class<?> _class) {
config().setName(_class.getName());
return this;
} | java | public final Cache2kBuilder<K, V> name(Class<?> _class) {
config().setName(_class.getName());
return this;
} | [
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"name",
"(",
"Class",
"<",
"?",
">",
"_class",
")",
"{",
"config",
"(",
")",
".",
"setName",
"(",
"_class",
".",
"getName",
"(",
")",
")",
";",
"return",
"this",
";",
"}"
] | Sets a cache name from the fully qualified class name.
<p>See {@link #name(String)} for a general discussion about cache names.
@see #name(String) | [
"Sets",
"a",
"cache",
"name",
"from",
"the",
"fully",
"qualified",
"class",
"name",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L288-L291 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.wrapCustomizationInstance | private static <T> CustomizationReferenceSupplier<T> wrapCustomizationInstance(T obj) {
if (obj == null) { return null; }
return new CustomizationReferenceSupplier<T>(obj);
} | java | private static <T> CustomizationReferenceSupplier<T> wrapCustomizationInstance(T obj) {
if (obj == null) { return null; }
return new CustomizationReferenceSupplier<T>(obj);
} | [
"private",
"static",
"<",
"T",
">",
"CustomizationReferenceSupplier",
"<",
"T",
">",
"wrapCustomizationInstance",
"(",
"T",
"obj",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"CustomizationReferenceSupplier"... | Wraps to factory but passes on nulls. | [
"Wraps",
"to",
"factory",
"but",
"passes",
"on",
"nulls",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L424-L427 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.wrappingLoader | @SuppressWarnings("unchecked")
public final Cache2kBuilder<K, V> wrappingLoader(AdvancedCacheLoader<K, LoadDetail<V>> l) {
config().setAdvancedLoader((
CustomizationSupplier<AdvancedCacheLoader<K, V>>) (Object) wrapCustomizationInstance(l));
return this;
} | java | @SuppressWarnings("unchecked")
public final Cache2kBuilder<K, V> wrappingLoader(AdvancedCacheLoader<K, LoadDetail<V>> l) {
config().setAdvancedLoader((
CustomizationSupplier<AdvancedCacheLoader<K, V>>) (Object) wrapCustomizationInstance(l));
return this;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"wrappingLoader",
"(",
"AdvancedCacheLoader",
"<",
"K",
",",
"LoadDetail",
"<",
"V",
">",
">",
"l",
")",
"{",
"config",
"(",
")",
".",
"setA... | Enables read through operation and sets a cache loader
@see CacheLoader for general discussion on cache loaders | [
"Enables",
"read",
"through",
"operation",
"and",
"sets",
"a",
"cache",
"loader"
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L482-L487 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.writer | public final Cache2kBuilder<K, V> writer(CacheWriter<K, V> w) {
config().setWriter(wrapCustomizationInstance(w));
return this;
} | java | public final Cache2kBuilder<K, V> writer(CacheWriter<K, V> w) {
config().setWriter(wrapCustomizationInstance(w));
return this;
} | [
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"writer",
"(",
"CacheWriter",
"<",
"K",
",",
"V",
">",
"w",
")",
"{",
"config",
"(",
")",
".",
"setWriter",
"(",
"wrapCustomizationInstance",
"(",
"w",
")",
")",
";",
"return",
"this",
";"... | Enables write through operation and sets a writer customization that gets
called synchronously upon cache mutations. By default write through is not enabled. | [
"Enables",
"write",
"through",
"operation",
"and",
"sets",
"a",
"writer",
"customization",
"that",
"gets",
"called",
"synchronously",
"upon",
"cache",
"mutations",
".",
"By",
"default",
"write",
"through",
"is",
"not",
"enabled",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L517-L520 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.addCacheClosedListener | public final Cache2kBuilder<K, V> addCacheClosedListener(CacheClosedListener listener) {
config().getCacheClosedListeners().add(wrapCustomizationInstance(listener));
return this;
} | java | public final Cache2kBuilder<K, V> addCacheClosedListener(CacheClosedListener listener) {
config().getCacheClosedListeners().add(wrapCustomizationInstance(listener));
return this;
} | [
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"addCacheClosedListener",
"(",
"CacheClosedListener",
"listener",
")",
"{",
"config",
"(",
")",
".",
"getCacheClosedListeners",
"(",
")",
".",
"add",
"(",
"wrapCustomizationInstance",
"(",
"listener",
... | Listener that is called after a cache is closed. This is mainly used for the JCache integration. | [
"Listener",
"that",
"is",
"called",
"after",
"a",
"cache",
"is",
"closed",
".",
"This",
"is",
"mainly",
"used",
"for",
"the",
"JCache",
"integration",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L525-L528 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.addListener | public final Cache2kBuilder<K, V> addListener(CacheEntryOperationListener<K,V> listener) {
config().getListeners().add(wrapCustomizationInstance(listener));
return this;
} | java | public final Cache2kBuilder<K, V> addListener(CacheEntryOperationListener<K,V> listener) {
config().getListeners().add(wrapCustomizationInstance(listener));
return this;
} | [
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"addListener",
"(",
"CacheEntryOperationListener",
"<",
"K",
",",
"V",
">",
"listener",
")",
"{",
"config",
"(",
")",
".",
"getListeners",
"(",
")",
".",
"add",
"(",
"wrapCustomizationInstance",
... | Add a listener. The listeners will be executed in a synchronous mode, meaning,
further processing for an entry will stall until a registered listener is executed.
The expiry will be always executed asynchronously.
@throws IllegalArgumentException if an identical listener is already added.
@param listener The listener... | [
"Add",
"a",
"listener",
".",
"The",
"listeners",
"will",
"be",
"executed",
"in",
"a",
"synchronous",
"mode",
"meaning",
"further",
"processing",
"for",
"an",
"entry",
"will",
"stall",
"until",
"a",
"registered",
"listener",
"is",
"executed",
".",
"The",
"exp... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L538-L541 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.addAsyncListener | public final Cache2kBuilder<K,V> addAsyncListener(CacheEntryOperationListener<K,V> listener) {
config().getAsyncListeners().add(wrapCustomizationInstance(listener));
return this;
} | java | public final Cache2kBuilder<K,V> addAsyncListener(CacheEntryOperationListener<K,V> listener) {
config().getAsyncListeners().add(wrapCustomizationInstance(listener));
return this;
} | [
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"addAsyncListener",
"(",
"CacheEntryOperationListener",
"<",
"K",
",",
"V",
">",
"listener",
")",
"{",
"config",
"(",
")",
".",
"getAsyncListeners",
"(",
")",
".",
"add",
"(",
"wrapCustomizationIn... | A set of listeners. Listeners added in this collection will be
executed in a asynchronous mode.
@throws IllegalArgumentException if an identical listener is already added.
@param listener The listener to add | [
"A",
"set",
"of",
"listeners",
".",
"Listeners",
"added",
"in",
"this",
"collection",
"will",
"be",
"executed",
"in",
"a",
"asynchronous",
"mode",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L550-L553 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.expiryPolicy | public final Cache2kBuilder<K, V> expiryPolicy(ExpiryPolicy<K, V> c) {
config().setExpiryPolicy(wrapCustomizationInstance(c));
return this;
} | java | public final Cache2kBuilder<K, V> expiryPolicy(ExpiryPolicy<K, V> c) {
config().setExpiryPolicy(wrapCustomizationInstance(c));
return this;
} | [
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"expiryPolicy",
"(",
"ExpiryPolicy",
"<",
"K",
",",
"V",
">",
"c",
")",
"{",
"config",
"(",
")",
".",
"setExpiryPolicy",
"(",
"wrapCustomizationInstance",
"(",
"c",
")",
")",
";",
"return",
... | Set expiry policy to use.
<p>If this is specified the maximum expiry time is still limited to the value in
{@link #expireAfterWrite}. If {@link #expireAfterWrite(long, java.util.concurrent.TimeUnit)}
is set to 0 then expiry calculation is not used, all entries expire immediately.
<p>If no maximum expiry is specified ... | [
"Set",
"expiry",
"policy",
"to",
"use",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L565-L568 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.maxRetryInterval | public final Cache2kBuilder<K, V> maxRetryInterval(long v, TimeUnit u) {
config().setMaxRetryInterval(u.toMillis(v));
return this;
} | java | public final Cache2kBuilder<K, V> maxRetryInterval(long v, TimeUnit u) {
config().setMaxRetryInterval(u.toMillis(v));
return this;
} | [
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"maxRetryInterval",
"(",
"long",
"v",
",",
"TimeUnit",
"u",
")",
"{",
"config",
"(",
")",
".",
"setMaxRetryInterval",
"(",
"u",
".",
"toMillis",
"(",
"v",
")",
")",
";",
"return",
"this",
... | If a loader exception happens, this is the maximum time interval after a
retry attempt is made. For retries an exponential backoff algorithm is used.
It starts with the retry time and then increases the time to the maximum
according to an exponential pattern.
<p>By default identical to {@link #resilienceDuration} | [
"If",
"a",
"loader",
"exception",
"happens",
"this",
"is",
"the",
"maximum",
"time",
"interval",
"after",
"a",
"retry",
"attempt",
"is",
"made",
".",
"For",
"retries",
"an",
"exponential",
"backoff",
"algorithm",
"is",
"used",
".",
"It",
"starts",
"with",
... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L656-L659 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.with | public final Cache2kBuilder<K, V> with(ConfigurationSectionBuilder<? extends ConfigurationSection>... sectionBuilders) {
for (ConfigurationSectionBuilder<? extends ConfigurationSection> b : sectionBuilders) {
config().getSections().add(b.buildConfigurationSection());
}
return this;
} | java | public final Cache2kBuilder<K, V> with(ConfigurationSectionBuilder<? extends ConfigurationSection>... sectionBuilders) {
for (ConfigurationSectionBuilder<? extends ConfigurationSection> b : sectionBuilders) {
config().getSections().add(b.buildConfigurationSection());
}
return this;
} | [
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"with",
"(",
"ConfigurationSectionBuilder",
"<",
"?",
"extends",
"ConfigurationSection",
">",
"...",
"sectionBuilders",
")",
"{",
"for",
"(",
"ConfigurationSectionBuilder",
"<",
"?",
"extends",
"Configu... | Add a new configuration sub section.
@see org.cache2k.configuration.ConfigurationWithSections | [
"Add",
"a",
"new",
"configuration",
"sub",
"section",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L690-L695 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.asyncListenerExecutor | public final Cache2kBuilder<K,V> asyncListenerExecutor(Executor v) {
config().setAsyncListenerExecutor(new CustomizationReferenceSupplier<Executor>(v));
return this;
} | java | public final Cache2kBuilder<K,V> asyncListenerExecutor(Executor v) {
config().setAsyncListenerExecutor(new CustomizationReferenceSupplier<Executor>(v));
return this;
} | [
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"asyncListenerExecutor",
"(",
"Executor",
"v",
")",
"{",
"config",
"(",
")",
".",
"setAsyncListenerExecutor",
"(",
"new",
"CustomizationReferenceSupplier",
"<",
"Executor",
">",
"(",
"v",
")",
")",
... | Executor for asynchronous listeners. If no executor is specified, an internal
executor is used that has unbounded thread capacity.
@see #addAsyncListener(CacheEntryOperationListener) | [
"Executor",
"for",
"asynchronous",
"listeners",
".",
"If",
"no",
"executor",
"is",
"specified",
"an",
"internal",
"executor",
"is",
"used",
"that",
"has",
"unbounded",
"thread",
"capacity",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L806-L809 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java | Cache2kBuilder.timeReference | public final Cache2kBuilder<K, V> timeReference(TimeReference v) {
config().setTimeReference(new CustomizationReferenceSupplier<TimeReference>(v));
return this;
} | java | public final Cache2kBuilder<K, V> timeReference(TimeReference v) {
config().setTimeReference(new CustomizationReferenceSupplier<TimeReference>(v));
return this;
} | [
"public",
"final",
"Cache2kBuilder",
"<",
"K",
",",
"V",
">",
"timeReference",
"(",
"TimeReference",
"v",
")",
"{",
"config",
"(",
")",
".",
"setTimeReference",
"(",
"new",
"CustomizationReferenceSupplier",
"<",
"TimeReference",
">",
"(",
"v",
")",
")",
";",... | Clock to be used by the cache as time reference. | [
"Clock",
"to",
"be",
"used",
"by",
"the",
"cache",
"as",
"time",
"reference",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/Cache2kBuilder.java#L814-L817 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/TimingHandler.java | TimingHandler.limitExpiryToMaxLinger | static long limitExpiryToMaxLinger(long now, long _maxLinger, long _requestedExpiryTime, boolean _sharpExpiryEnabled) {
if (_sharpExpiryEnabled && _requestedExpiryTime > ExpiryPolicy.REFRESH && _requestedExpiryTime < ExpiryPolicy.ETERNAL) {
_requestedExpiryTime = -_requestedExpiryTime;
}
return Expiry... | java | static long limitExpiryToMaxLinger(long now, long _maxLinger, long _requestedExpiryTime, boolean _sharpExpiryEnabled) {
if (_sharpExpiryEnabled && _requestedExpiryTime > ExpiryPolicy.REFRESH && _requestedExpiryTime < ExpiryPolicy.ETERNAL) {
_requestedExpiryTime = -_requestedExpiryTime;
}
return Expiry... | [
"static",
"long",
"limitExpiryToMaxLinger",
"(",
"long",
"now",
",",
"long",
"_maxLinger",
",",
"long",
"_requestedExpiryTime",
",",
"boolean",
"_sharpExpiryEnabled",
")",
"{",
"if",
"(",
"_sharpExpiryEnabled",
"&&",
"_requestedExpiryTime",
">",
"ExpiryPolicy",
".",
... | Ignore the value of the expiry policy if later then the maximum expiry time.
If max linger takes over, we do not request sharp expiry.
<p>The situation becomes messy if the point in time for the maximum expiry is
close to the requested expiry time and sharp expiry is requested. The expiry or
a reload (with refresh ahe... | [
"Ignore",
"the",
"value",
"of",
"the",
"expiry",
"policy",
"if",
"later",
"then",
"the",
"maximum",
"expiry",
"time",
".",
"If",
"max",
"linger",
"takes",
"over",
"we",
"do",
"not",
"request",
"sharp",
"expiry",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/TimingHandler.java#L619-L624 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/impl/xmlConfiguration/CacheConfigurationProviderImpl.java | CacheConfigurationProviderImpl.getDefaultManagerName | @Override
public String getDefaultManagerName(ClassLoader cl) {
ConfigurationContext ctx = classLoader2config.get(cl);
if (ctx == null) {
ctx = createContext(cl, null, DEFAULT_CONFIGURATION_FILE);
Map<ClassLoader, ConfigurationContext> m2 = new HashMap<ClassLoader, ConfigurationContext>(classLoade... | java | @Override
public String getDefaultManagerName(ClassLoader cl) {
ConfigurationContext ctx = classLoader2config.get(cl);
if (ctx == null) {
ctx = createContext(cl, null, DEFAULT_CONFIGURATION_FILE);
Map<ClassLoader, ConfigurationContext> m2 = new HashMap<ClassLoader, ConfigurationContext>(classLoade... | [
"@",
"Override",
"public",
"String",
"getDefaultManagerName",
"(",
"ClassLoader",
"cl",
")",
"{",
"ConfigurationContext",
"ctx",
"=",
"classLoader2config",
".",
"get",
"(",
"cl",
")",
";",
"if",
"(",
"ctx",
"==",
"null",
")",
"{",
"ctx",
"=",
"createContext"... | The name of the default manager may be changed in the configuration file.
Load the default configuration file and save the loaded context for the respective
classloader, so we do not load the context twice when we create the first cache. | [
"The",
"name",
"of",
"the",
"default",
"manager",
"may",
"be",
"changed",
"in",
"the",
"configuration",
"file",
".",
"Load",
"the",
"default",
"configuration",
"file",
"and",
"save",
"the",
"loaded",
"context",
"for",
"the",
"respective",
"classloader",
"so",
... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/impl/xmlConfiguration/CacheConfigurationProviderImpl.java#L76-L86 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/impl/xmlConfiguration/CacheConfigurationProviderImpl.java | CacheConfigurationProviderImpl.getManagerContext | private ConfigurationContext getManagerContext(final CacheManager mgr) {
ConfigurationContext ctx = manager2defaultConfig.get(mgr);
if (ctx != null) {
return ctx;
}
synchronized (this) {
ctx = manager2defaultConfig.get(mgr);
if (ctx != null) {
return ctx;
}
if (mgr.... | java | private ConfigurationContext getManagerContext(final CacheManager mgr) {
ConfigurationContext ctx = manager2defaultConfig.get(mgr);
if (ctx != null) {
return ctx;
}
synchronized (this) {
ctx = manager2defaultConfig.get(mgr);
if (ctx != null) {
return ctx;
}
if (mgr.... | [
"private",
"ConfigurationContext",
"getManagerContext",
"(",
"final",
"CacheManager",
"mgr",
")",
"{",
"ConfigurationContext",
"ctx",
"=",
"manager2defaultConfig",
".",
"get",
"(",
"mgr",
")",
";",
"if",
"(",
"ctx",
"!=",
"null",
")",
"{",
"return",
"ctx",
";"... | Hold the cache default configuration of a manager in a hash table. This is reused for all caches of
one manager. | [
"Hold",
"the",
"cache",
"default",
"configuration",
"of",
"a",
"manager",
"in",
"a",
"hash",
"table",
".",
"This",
"is",
"reused",
"for",
"all",
"caches",
"of",
"one",
"manager",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/impl/xmlConfiguration/CacheConfigurationProviderImpl.java#L186-L208 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/impl/xmlConfiguration/CacheConfigurationProviderImpl.java | CacheConfigurationProviderImpl.apply | void apply(final ConfigurationContext ctx, final ParsedConfiguration _parsedCfg, final Object cfg) {
ParsedConfiguration _templates = ctx.getTemplates();
ConfigurationTokenizer.Property _include = _parsedCfg.getPropertyMap().get("include");
if (_include != null) {
for (String _template : _include.getV... | java | void apply(final ConfigurationContext ctx, final ParsedConfiguration _parsedCfg, final Object cfg) {
ParsedConfiguration _templates = ctx.getTemplates();
ConfigurationTokenizer.Property _include = _parsedCfg.getPropertyMap().get("include");
if (_include != null) {
for (String _template : _include.getV... | [
"void",
"apply",
"(",
"final",
"ConfigurationContext",
"ctx",
",",
"final",
"ParsedConfiguration",
"_parsedCfg",
",",
"final",
"Object",
"cfg",
")",
"{",
"ParsedConfiguration",
"_templates",
"=",
"ctx",
".",
"getTemplates",
"(",
")",
";",
"ConfigurationTokenizer",
... | Set properties in configuration bean based on the parsed configuration. Called by unit test. | [
"Set",
"properties",
"in",
"configuration",
"bean",
"based",
"on",
"the",
"parsed",
"configuration",
".",
"Called",
"by",
"unit",
"test",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/impl/xmlConfiguration/CacheConfigurationProviderImpl.java#L272-L311 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/impl/xmlConfiguration/CacheConfigurationProviderImpl.java | CacheConfigurationProviderImpl.handleBean | private boolean handleBean(
final ConfigurationContext ctx,
final Class<?> _type,
final Object cfg,
final ParsedConfiguration _parsedCfg) {
String _containerName = _parsedCfg.getContainer();
BeanPropertyMutator m = provideMutator(cfg.getClass());
Class<?> _targetType = m.getType(_containerNa... | java | private boolean handleBean(
final ConfigurationContext ctx,
final Class<?> _type,
final Object cfg,
final ParsedConfiguration _parsedCfg) {
String _containerName = _parsedCfg.getContainer();
BeanPropertyMutator m = provideMutator(cfg.getClass());
Class<?> _targetType = m.getType(_containerNa... | [
"private",
"boolean",
"handleBean",
"(",
"final",
"ConfigurationContext",
"ctx",
",",
"final",
"Class",
"<",
"?",
">",
"_type",
",",
"final",
"Object",
"cfg",
",",
"final",
"ParsedConfiguration",
"_parsedCfg",
")",
"{",
"String",
"_containerName",
"=",
"_parsedC... | Create the bean, apply configuration to it and set it.
@return true, if applied, false if not a property | [
"Create",
"the",
"bean",
"apply",
"configuration",
"to",
"it",
"and",
"set",
"it",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/impl/xmlConfiguration/CacheConfigurationProviderImpl.java#L318-L335 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/impl/xmlConfiguration/CacheConfigurationProviderImpl.java | CacheConfigurationProviderImpl.handleSection | private boolean handleSection(
final ConfigurationContext ctx,
final Class<?> _type,
final ConfigurationWithSections cfg,
final ParsedConfiguration sc) {
String _containerName = sc.getContainer();
if (!"sections".equals(_containerName)) {
return false;
}
@SuppressWarnings("unchecke... | java | private boolean handleSection(
final ConfigurationContext ctx,
final Class<?> _type,
final ConfigurationWithSections cfg,
final ParsedConfiguration sc) {
String _containerName = sc.getContainer();
if (!"sections".equals(_containerName)) {
return false;
}
@SuppressWarnings("unchecke... | [
"private",
"boolean",
"handleSection",
"(",
"final",
"ConfigurationContext",
"ctx",
",",
"final",
"Class",
"<",
"?",
">",
"_type",
",",
"final",
"ConfigurationWithSections",
"cfg",
",",
"final",
"ParsedConfiguration",
"sc",
")",
"{",
"String",
"_containerName",
"=... | Create a new configuration section or reuse an existing section, if it is a singleton.
<p>No support for writing on existing sections, which means it is not possible to define a non singleton
in the defaults section and then override values later in the cache specific configuration.
This is not needed for version 1.0.... | [
"Create",
"a",
"new",
"configuration",
"section",
"or",
"reuse",
"an",
"existing",
"section",
"if",
"it",
"is",
"a",
"singleton",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/impl/xmlConfiguration/CacheConfigurationProviderImpl.java#L410-L430 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/EntryAction.java | EntryAction.checkKeepOrRemove | public void checkKeepOrRemove() {
boolean _hasKeepAfterExpired = heapCache.isKeepAfterExpired();
if (expiry != 0 || remove || _hasKeepAfterExpired) {
mutationUpdateHeap();
return;
}
if (_hasKeepAfterExpired) {
expiredImmediatelyKeepData();
return;
}
expiredImmediatelyAndR... | java | public void checkKeepOrRemove() {
boolean _hasKeepAfterExpired = heapCache.isKeepAfterExpired();
if (expiry != 0 || remove || _hasKeepAfterExpired) {
mutationUpdateHeap();
return;
}
if (_hasKeepAfterExpired) {
expiredImmediatelyKeepData();
return;
}
expiredImmediatelyAndR... | [
"public",
"void",
"checkKeepOrRemove",
"(",
")",
"{",
"boolean",
"_hasKeepAfterExpired",
"=",
"heapCache",
".",
"isKeepAfterExpired",
"(",
")",
";",
"if",
"(",
"expiry",
"!=",
"0",
"||",
"remove",
"||",
"_hasKeepAfterExpired",
")",
"{",
"mutationUpdateHeap",
"("... | In case we have a expiry of 0, this means that the entry should
not be cached. If there is a valid entry, we remove it if we do not
keep the data. | [
"In",
"case",
"we",
"have",
"a",
"expiry",
"of",
"0",
"this",
"means",
"that",
"the",
"entry",
"should",
"not",
"be",
"cached",
".",
"If",
"there",
"is",
"a",
"valid",
"entry",
"we",
"remove",
"it",
"if",
"we",
"do",
"not",
"keep",
"the",
"data",
"... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/EntryAction.java#L773-L784 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/EntryAction.java | EntryAction.asyncOperationStarted | public void asyncOperationStarted() {
if (syncThread == Thread.currentThread()) {
synchronized (entry) {
while (entry.isProcessing()) {
try {
entry.wait();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}
... | java | public void asyncOperationStarted() {
if (syncThread == Thread.currentThread()) {
synchronized (entry) {
while (entry.isProcessing()) {
try {
entry.wait();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
}
... | [
"public",
"void",
"asyncOperationStarted",
"(",
")",
"{",
"if",
"(",
"syncThread",
"==",
"Thread",
".",
"currentThread",
"(",
")",
")",
"{",
"synchronized",
"(",
"entry",
")",
"{",
"while",
"(",
"entry",
".",
"isProcessing",
"(",
")",
")",
"{",
"try",
... | If thread is a synchronous call, wait until operation is complete.
There is a little chance that the call back completes before we get
here as well as some other operation changing the entry again. | [
"If",
"thread",
"is",
"a",
"synchronous",
"call",
"wait",
"until",
"operation",
"is",
"complete",
".",
"There",
"is",
"a",
"little",
"chance",
"that",
"the",
"call",
"back",
"completes",
"before",
"we",
"get",
"here",
"as",
"well",
"as",
"some",
"other",
... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/EntryAction.java#L1004-L1018 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/util/Log.java | Log.initializeLogFactory | private static void initializeLogFactory() {
ServiceLoader<LogFactory> loader = ServiceLoader.load(LogFactory.class);
for (LogFactory lf : loader) {
logFactory = lf;
log("New instance, using: " + logFactory.getClass().getName());
return;
}
try {
final org.slf4j.ILoggerFactory lf ... | java | private static void initializeLogFactory() {
ServiceLoader<LogFactory> loader = ServiceLoader.load(LogFactory.class);
for (LogFactory lf : loader) {
logFactory = lf;
log("New instance, using: " + logFactory.getClass().getName());
return;
}
try {
final org.slf4j.ILoggerFactory lf ... | [
"private",
"static",
"void",
"initializeLogFactory",
"(",
")",
"{",
"ServiceLoader",
"<",
"LogFactory",
">",
"loader",
"=",
"ServiceLoader",
".",
"load",
"(",
"LogFactory",
".",
"class",
")",
";",
"for",
"(",
"LogFactory",
"lf",
":",
"loader",
")",
"{",
"l... | Finds a logger we can use. First we start with looking for a registered
service provider. Then apache commons logging. As a fallback we use JDK logging. | [
"Finds",
"a",
"logger",
"we",
"can",
"use",
".",
"First",
"we",
"start",
"with",
"looking",
"for",
"a",
"registered",
"service",
"provider",
".",
"Then",
"apache",
"commons",
"logging",
".",
"As",
"a",
"fallback",
"we",
"use",
"JDK",
"logging",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/util/Log.java#L73-L112 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/spi/SingleProviderResolver.java | SingleProviderResolver.readFile | private static String readFile(String _name) throws IOException {
InputStream in = SingleProviderResolver.class.getClassLoader().getResourceAsStream(_name);
if (in == null) {
return null;
}
try {
LineNumberReader r = new LineNumberReader(new InputStreamReader(in));
String l = r.readLin... | java | private static String readFile(String _name) throws IOException {
InputStream in = SingleProviderResolver.class.getClassLoader().getResourceAsStream(_name);
if (in == null) {
return null;
}
try {
LineNumberReader r = new LineNumberReader(new InputStreamReader(in));
String l = r.readLin... | [
"private",
"static",
"String",
"readFile",
"(",
"String",
"_name",
")",
"throws",
"IOException",
"{",
"InputStream",
"in",
"=",
"SingleProviderResolver",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"_name",
")",
";",
"if",
"... | Read the first line of a file in the classpath into a string. | [
"Read",
"the",
"first",
"line",
"of",
"a",
"file",
"in",
"the",
"classpath",
"into",
"a",
"string",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/spi/SingleProviderResolver.java#L127-L145 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/CacheManagerImpl.java | CacheManagerImpl.constructAllServiceImplementations | @SuppressWarnings("unchecked")
private static <S> Iterable<S> constructAllServiceImplementations(Class<S> _service) {
ClassLoader cl = CacheManagerImpl.class.getClassLoader();
ArrayList<S> li = new ArrayList<S>();
Iterator<S> it = ServiceLoader.load(_service, cl).iterator();
while (it.hasNext()) {
... | java | @SuppressWarnings("unchecked")
private static <S> Iterable<S> constructAllServiceImplementations(Class<S> _service) {
ClassLoader cl = CacheManagerImpl.class.getClassLoader();
ArrayList<S> li = new ArrayList<S>();
Iterator<S> it = ServiceLoader.load(_service, cl).iterator();
while (it.hasNext()) {
... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"static",
"<",
"S",
">",
"Iterable",
"<",
"S",
">",
"constructAllServiceImplementations",
"(",
"Class",
"<",
"S",
">",
"_service",
")",
"{",
"ClassLoader",
"cl",
"=",
"CacheManagerImpl",
".",
"clas... | The service loader works lazy, however, we want to have all implementations constructed.
Retrieve all implementations from the service loader and return an read-only iterable
backed by an array. | [
"The",
"service",
"loader",
"works",
"lazy",
"however",
"we",
"want",
"to",
"have",
"all",
"implementations",
"constructed",
".",
"Retrieve",
"all",
"implementations",
"from",
"the",
"service",
"loader",
"and",
"return",
"an",
"read",
"-",
"only",
"iterable",
... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/CacheManagerImpl.java#L65-L95 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/CacheManagerImpl.java | CacheManagerImpl.checkName | public static void checkName(String s) {
for (char c : s.toCharArray()) {
if (c == '.' ||
c == '-' ||
c == '~' ||
c == ',' ||
c == '@' ||
c == ' ' ||
c == '(' ||
c == ')' ||
c == '+' ||
c == '!' ||
c == '\'' ||... | java | public static void checkName(String s) {
for (char c : s.toCharArray()) {
if (c == '.' ||
c == '-' ||
c == '~' ||
c == ',' ||
c == '@' ||
c == ' ' ||
c == '(' ||
c == ')' ||
c == '+' ||
c == '!' ||
c == '\'' ||... | [
"public",
"static",
"void",
"checkName",
"(",
"String",
"s",
")",
"{",
"for",
"(",
"char",
"c",
":",
"s",
".",
"toCharArray",
"(",
")",
")",
"{",
"if",
"(",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
"||",
"c... | Don't accept a cache or manager names with too weird characters.
@see org.cache2k.Cache2kBuilder#name(String) | [
"Don",
"t",
"accept",
"a",
"cache",
"or",
"manager",
"names",
"with",
"too",
"weird",
"characters",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/CacheManagerImpl.java#L140-L162 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/CacheManagerImpl.java | CacheManagerImpl.close | @Override
public void close() {
if (isDefaultManager() && getClass().getClassLoader() == classLoader) {
log.info("Closing default CacheManager");
}
Iterable<Cache> _caches;
synchronized (lock) {
if (closing) {
return;
}
_caches = cachesCopy();
closing = true;
... | java | @Override
public void close() {
if (isDefaultManager() && getClass().getClassLoader() == classLoader) {
log.info("Closing default CacheManager");
}
Iterable<Cache> _caches;
synchronized (lock) {
if (closing) {
return;
}
_caches = cachesCopy();
closing = true;
... | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"isDefaultManager",
"(",
")",
"&&",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
"==",
"classLoader",
")",
"{",
"log",
".",
"info",
"(",
"\"Closing default CacheManager\"",
")"... | The shutdown takes place in two phases. First all caches are notified to
cancel their scheduled timer jobs, after that the shutdown is done. Cancelling
the timer jobs first is needed, because there may be cache stacking and
a timer job of one cache may call an already closed cache.
<p>Rationale exception handling: Exc... | [
"The",
"shutdown",
"takes",
"place",
"in",
"two",
"phases",
".",
"First",
"all",
"caches",
"are",
"notified",
"to",
"cancel",
"their",
"scheduled",
"timer",
"jobs",
"after",
"that",
"the",
"shutdown",
"is",
"done",
".",
"Cancelling",
"the",
"timer",
"jobs",
... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/CacheManagerImpl.java#L275-L315 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/CacheManagerImpl.java | CacheManagerImpl.eventuallyThrowException | static void eventuallyThrowException(List<Throwable> _suppressedExceptions) {
if (_suppressedExceptions.isEmpty()) {
return;
}
Throwable _error = null;
for (Throwable t : _suppressedExceptions) {
if (t instanceof Error) { _error = t; break; }
if (t instanceof ExecutionException &&
... | java | static void eventuallyThrowException(List<Throwable> _suppressedExceptions) {
if (_suppressedExceptions.isEmpty()) {
return;
}
Throwable _error = null;
for (Throwable t : _suppressedExceptions) {
if (t instanceof Error) { _error = t; break; }
if (t instanceof ExecutionException &&
... | [
"static",
"void",
"eventuallyThrowException",
"(",
"List",
"<",
"Throwable",
">",
"_suppressedExceptions",
")",
"{",
"if",
"(",
"_suppressedExceptions",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"Throwable",
"_error",
"=",
"null",
";",
"for",
"... | During the shutdown of the cache manager multiple exceptions can happen from
various caches. The list of exceptions gets examined to throw one exception.
<p>If an error is present, the first found gets thrown as CacheInternalError.
If no error is present the first normal exception gets thrown as CacheException.
<p>Th... | [
"During",
"the",
"shutdown",
"of",
"the",
"cache",
"manager",
"multiple",
"exceptions",
"can",
"happen",
"from",
"various",
"caches",
".",
"The",
"list",
"of",
"exceptions",
"gets",
"examined",
"to",
"throw",
"one",
"exception",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/CacheManagerImpl.java#L330-L351 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/CacheManagerImpl.java | CacheManagerImpl.getManagerId | private String getManagerId() {
return "name='" + name +
"', objectId=" + Integer.toString(System.identityHashCode(this), 36) +
", classloaderId=" + Integer.toString(System.identityHashCode(classLoader), 36) +
", default=" + defaultManager;
} | java | private String getManagerId() {
return "name='" + name +
"', objectId=" + Integer.toString(System.identityHashCode(this), 36) +
", classloaderId=" + Integer.toString(System.identityHashCode(classLoader), 36) +
", default=" + defaultManager;
} | [
"private",
"String",
"getManagerId",
"(",
")",
"{",
"return",
"\"name='\"",
"+",
"name",
"+",
"\"', objectId=\"",
"+",
"Integer",
".",
"toString",
"(",
"System",
".",
"identityHashCode",
"(",
"this",
")",
",",
"36",
")",
"+",
"\", classloaderId=\"",
"+",
"In... | Relevant information to id a manager. Since there could be multiple cache managers for each class loader,
better | [
"Relevant",
"information",
"to",
"id",
"a",
"manager",
".",
"Since",
"there",
"could",
"be",
"multiple",
"cache",
"managers",
"for",
"each",
"class",
"loader",
"better"
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/CacheManagerImpl.java#L399-L404 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Entry.java | Entry.checkAndSwitchProcessingState | public boolean checkAndSwitchProcessingState(int ps0, int ps) {
long rt = refreshTimeAndState;
long _expect = withState(rt, ps0);
long _update = withState(rt, ps);
return STATE_UPDATER.compareAndSet(this, _expect, _update);
} | java | public boolean checkAndSwitchProcessingState(int ps0, int ps) {
long rt = refreshTimeAndState;
long _expect = withState(rt, ps0);
long _update = withState(rt, ps);
return STATE_UPDATER.compareAndSet(this, _expect, _update);
} | [
"public",
"boolean",
"checkAndSwitchProcessingState",
"(",
"int",
"ps0",
",",
"int",
"ps",
")",
"{",
"long",
"rt",
"=",
"refreshTimeAndState",
";",
"long",
"_expect",
"=",
"withState",
"(",
"rt",
",",
"ps0",
")",
";",
"long",
"_update",
"=",
"withState",
"... | Check and switch the processing state atomically. | [
"Check",
"and",
"switch",
"the",
"processing",
"state",
"atomically",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Entry.java#L315-L320 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Entry.java | Entry.existingPiggyBackForInserting | private PiggyBack existingPiggyBackForInserting() {
Object _misc = misc;
if (_misc instanceof SimpleTimerTask) {
return new TaskPiggyBack((SimpleTimerTask) _misc, null);
}
return (PiggyBack) _misc;
} | java | private PiggyBack existingPiggyBackForInserting() {
Object _misc = misc;
if (_misc instanceof SimpleTimerTask) {
return new TaskPiggyBack((SimpleTimerTask) _misc, null);
}
return (PiggyBack) _misc;
} | [
"private",
"PiggyBack",
"existingPiggyBackForInserting",
"(",
")",
"{",
"Object",
"_misc",
"=",
"misc",
";",
"if",
"(",
"_misc",
"instanceof",
"SimpleTimerTask",
")",
"{",
"return",
"new",
"TaskPiggyBack",
"(",
"(",
"SimpleTimerTask",
")",
"_misc",
",",
"null",
... | We want to add a new piggy back. Check for timer task and convert it to
piggy back. | [
"We",
"want",
"to",
"add",
"a",
"new",
"piggy",
"back",
".",
"Check",
"for",
"timer",
"task",
"and",
"convert",
"it",
"to",
"piggy",
"back",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Entry.java#L644-L650 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Entry.java | Entry.resetSuppressedLoadExceptionInformation | public void resetSuppressedLoadExceptionInformation() {
LoadExceptionPiggyBack inf = getPiggyBack(LoadExceptionPiggyBack.class);
if (inf != null) {
inf.info = null;
}
} | java | public void resetSuppressedLoadExceptionInformation() {
LoadExceptionPiggyBack inf = getPiggyBack(LoadExceptionPiggyBack.class);
if (inf != null) {
inf.info = null;
}
} | [
"public",
"void",
"resetSuppressedLoadExceptionInformation",
"(",
")",
"{",
"LoadExceptionPiggyBack",
"inf",
"=",
"getPiggyBack",
"(",
"LoadExceptionPiggyBack",
".",
"class",
")",
";",
"if",
"(",
"inf",
"!=",
"null",
")",
"{",
"inf",
".",
"info",
"=",
"null",
... | If the entry carries information about a suppressed exception, clear it. | [
"If",
"the",
"entry",
"carries",
"information",
"about",
"a",
"suppressed",
"exception",
"clear",
"it",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Entry.java#L664-L669 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Hash2.java | Hash2.lookup | public Entry<K,V> lookup(K key, int _hash, int _keyValue) {
OptimisticLock[] _locks = locks;
int si = _hash & LOCK_MASK;
OptimisticLock l = _locks[si];
long _stamp = l.tryOptimisticRead();
Entry<K,V>[] tab = entries;
if (tab == null) {
throw new CacheClosedException(cache);
}
Entry... | java | public Entry<K,V> lookup(K key, int _hash, int _keyValue) {
OptimisticLock[] _locks = locks;
int si = _hash & LOCK_MASK;
OptimisticLock l = _locks[si];
long _stamp = l.tryOptimisticRead();
Entry<K,V>[] tab = entries;
if (tab == null) {
throw new CacheClosedException(cache);
}
Entry... | [
"public",
"Entry",
"<",
"K",
",",
"V",
">",
"lookup",
"(",
"K",
"key",
",",
"int",
"_hash",
",",
"int",
"_keyValue",
")",
"{",
"OptimisticLock",
"[",
"]",
"_locks",
"=",
"locks",
";",
"int",
"si",
"=",
"_hash",
"&",
"LOCK_MASK",
";",
"OptimisticLock"... | Lookup the entry in the hash table and return it. First tries an optimistic read. | [
"Lookup",
"the",
"entry",
"in",
"the",
"hash",
"table",
"and",
"return",
"it",
".",
"First",
"tries",
"an",
"optimistic",
"read",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Hash2.java#L109-L152 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Hash2.java | Hash2.insertWithinLock | public Entry<K,V> insertWithinLock(Entry<K,V> e, int _hash, int _keyValue) {
K key = e.getKeyObj();
int si = _hash & LOCK_MASK;
Entry<K,V> f; Object ek; Entry<K,V>[] tab = entries;
if (tab == null) {
throw new CacheClosedException(cache);
}
int n = tab.length, _mask = n - 1, idx = _hash & ... | java | public Entry<K,V> insertWithinLock(Entry<K,V> e, int _hash, int _keyValue) {
K key = e.getKeyObj();
int si = _hash & LOCK_MASK;
Entry<K,V> f; Object ek; Entry<K,V>[] tab = entries;
if (tab == null) {
throw new CacheClosedException(cache);
}
int n = tab.length, _mask = n - 1, idx = _hash & ... | [
"public",
"Entry",
"<",
"K",
",",
"V",
">",
"insertWithinLock",
"(",
"Entry",
"<",
"K",
",",
"V",
">",
"e",
",",
"int",
"_hash",
",",
"int",
"_keyValue",
")",
"{",
"K",
"key",
"=",
"e",
".",
"getKeyObj",
"(",
")",
";",
"int",
"si",
"=",
"_hash"... | Insert an entry. Checks if an entry already exists. | [
"Insert",
"an",
"entry",
".",
"Checks",
"if",
"an",
"entry",
"already",
"exists",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Hash2.java#L164-L183 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Hash2.java | Hash2.remove | public boolean remove(Entry<K,V> e) {
int _hash = modifiedHashCode(e.hashCode);
OptimisticLock[] _locks = locks;
int si = _hash & LOCK_MASK;
OptimisticLock l = _locks[si];
long _stamp = l.writeLock();
try {
Entry<K,V> f; Entry<K,V>[] tab = entries;
if (tab == null) {
throw ne... | java | public boolean remove(Entry<K,V> e) {
int _hash = modifiedHashCode(e.hashCode);
OptimisticLock[] _locks = locks;
int si = _hash & LOCK_MASK;
OptimisticLock l = _locks[si];
long _stamp = l.writeLock();
try {
Entry<K,V> f; Entry<K,V>[] tab = entries;
if (tab == null) {
throw ne... | [
"public",
"boolean",
"remove",
"(",
"Entry",
"<",
"K",
",",
"V",
">",
"e",
")",
"{",
"int",
"_hash",
"=",
"modifiedHashCode",
"(",
"e",
".",
"hashCode",
")",
";",
"OptimisticLock",
"[",
"]",
"_locks",
"=",
"locks",
";",
"int",
"si",
"=",
"_hash",
"... | Remove existing entry from the hash.
@return true, if entry was found and removed. | [
"Remove",
"existing",
"entry",
"from",
"the",
"hash",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Hash2.java#L210-L241 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Hash2.java | Hash2.eventuallyExpand | private void eventuallyExpand(int _segmentIndex) {
long[] _stamps = lockAll();
try {
long _size = segmentSize[_segmentIndex].get();
if (_size <= segmentMaxFill) {
return;
}
rehash();
} finally {
unlockAll(_stamps);
}
} | java | private void eventuallyExpand(int _segmentIndex) {
long[] _stamps = lockAll();
try {
long _size = segmentSize[_segmentIndex].get();
if (_size <= segmentMaxFill) {
return;
}
rehash();
} finally {
unlockAll(_stamps);
}
} | [
"private",
"void",
"eventuallyExpand",
"(",
"int",
"_segmentIndex",
")",
"{",
"long",
"[",
"]",
"_stamps",
"=",
"lockAll",
"(",
")",
";",
"try",
"{",
"long",
"_size",
"=",
"segmentSize",
"[",
"_segmentIndex",
"]",
".",
"get",
"(",
")",
";",
"if",
"(",
... | Acquire all segment locks and rehash, if really needed. | [
"Acquire",
"all",
"segment",
"locks",
"and",
"rehash",
"if",
"really",
"needed",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Hash2.java#L272-L283 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Hash2.java | Hash2.lockAll | private long[] lockAll() {
OptimisticLock[] _locks = locks;
int sn = _locks.length;
long[] _stamps = new long[locks.length];
for (int i = 0; i < sn; i++) {
OptimisticLock l = _locks[i];
_stamps[i] = l.writeLock();
}
return _stamps;
} | java | private long[] lockAll() {
OptimisticLock[] _locks = locks;
int sn = _locks.length;
long[] _stamps = new long[locks.length];
for (int i = 0; i < sn; i++) {
OptimisticLock l = _locks[i];
_stamps[i] = l.writeLock();
}
return _stamps;
} | [
"private",
"long",
"[",
"]",
"lockAll",
"(",
")",
"{",
"OptimisticLock",
"[",
"]",
"_locks",
"=",
"locks",
";",
"int",
"sn",
"=",
"_locks",
".",
"length",
";",
"long",
"[",
"]",
"_stamps",
"=",
"new",
"long",
"[",
"locks",
".",
"length",
"]",
";",
... | Acquire all segment locks and return an array with the lock stamps. | [
"Acquire",
"all",
"segment",
"locks",
"and",
"return",
"an",
"array",
"with",
"the",
"lock",
"stamps",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Hash2.java#L288-L297 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Hash2.java | Hash2.unlockAll | private void unlockAll(long[] _stamps) {
OptimisticLock[] _locks = locks;
int sn = _locks.length;
for (int i = 0; i < sn; i++) {
_locks[i].unlockWrite(_stamps[i]);
}
} | java | private void unlockAll(long[] _stamps) {
OptimisticLock[] _locks = locks;
int sn = _locks.length;
for (int i = 0; i < sn; i++) {
_locks[i].unlockWrite(_stamps[i]);
}
} | [
"private",
"void",
"unlockAll",
"(",
"long",
"[",
"]",
"_stamps",
")",
"{",
"OptimisticLock",
"[",
"]",
"_locks",
"=",
"locks",
";",
"int",
"sn",
"=",
"_locks",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sn",
";",
"i",
... | Release the all segment locks.
@param _stamps array with the lock stamps. | [
"Release",
"the",
"all",
"segment",
"locks",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Hash2.java#L304-L310 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Hash2.java | Hash2.rehash | @SuppressWarnings("unchecked")
void rehash() {
Entry<K,V>[] src = entries;
if (src == null) {
throw new CacheClosedException(cache);
}
int i, sl = src.length, n = sl * 2, _mask = n - 1, idx;
Entry<K,V>[] tab = new Entry[n];
long _count = 0; Entry _next, e;
for (i = 0; i < sl; i++) {
... | java | @SuppressWarnings("unchecked")
void rehash() {
Entry<K,V>[] src = entries;
if (src == null) {
throw new CacheClosedException(cache);
}
int i, sl = src.length, n = sl * 2, _mask = n - 1, idx;
Entry<K,V>[] tab = new Entry[n];
long _count = 0; Entry _next, e;
for (i = 0; i < sl; i++) {
... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"void",
"rehash",
"(",
")",
"{",
"Entry",
"<",
"K",
",",
"V",
">",
"[",
"]",
"src",
"=",
"entries",
";",
"if",
"(",
"src",
"==",
"null",
")",
"{",
"throw",
"new",
"CacheClosedException",
"(",
"cache... | Double the hash table size and rehash the entries. Assumes total lock. | [
"Double",
"the",
"hash",
"table",
"size",
"and",
"rehash",
"the",
"entries",
".",
"Assumes",
"total",
"lock",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Hash2.java#L319-L338 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Hash2.java | Hash2.runTotalLocked | public <T> T runTotalLocked(Job<T> j) {
long[] _stamps = lockAll();
try {
return j.call();
} finally {
unlockAll(_stamps);
}
} | java | public <T> T runTotalLocked(Job<T> j) {
long[] _stamps = lockAll();
try {
return j.call();
} finally {
unlockAll(_stamps);
}
} | [
"public",
"<",
"T",
">",
"T",
"runTotalLocked",
"(",
"Job",
"<",
"T",
">",
"j",
")",
"{",
"long",
"[",
"]",
"_stamps",
"=",
"lockAll",
"(",
")",
";",
"try",
"{",
"return",
"j",
".",
"call",
"(",
")",
";",
"}",
"finally",
"{",
"unlockAll",
"(",
... | Lock all segments and run the job. | [
"Lock",
"all",
"segments",
"and",
"run",
"the",
"job",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Hash2.java#L351-L358 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Hash2.java | Hash2.calcEntryCount | public long calcEntryCount() {
long _count = 0;
for (Entry e : entries) {
while (e != null) {
_count++;
e = e.another;
}
}
return _count;
} | java | public long calcEntryCount() {
long _count = 0;
for (Entry e : entries) {
while (e != null) {
_count++;
e = e.another;
}
}
return _count;
} | [
"public",
"long",
"calcEntryCount",
"(",
")",
"{",
"long",
"_count",
"=",
"0",
";",
"for",
"(",
"Entry",
"e",
":",
"entries",
")",
"{",
"while",
"(",
"e",
"!=",
"null",
")",
"{",
"_count",
"++",
";",
"e",
"=",
"e",
".",
"another",
";",
"}",
"}"... | Count the entries in the hash table, by scanning through the hash table.
This is used for integrity checks. | [
"Count",
"the",
"entries",
"in",
"the",
"hash",
"table",
"by",
"scanning",
"through",
"the",
"hash",
"table",
".",
"This",
"is",
"used",
"for",
"integrity",
"checks",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Hash2.java#L409-L418 | train |
cache2k/cache2k | cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheManagerAdapter.java | JCacheManagerAdapter.findJCacheJmxSupportInstance | private static JCacheJmxSupport findJCacheJmxSupportInstance() {
for (CacheLifeCycleListener l : CacheManagerImpl.getCacheLifeCycleListeners()) {
if (l instanceof JCacheJmxSupport) {
return (JCacheJmxSupport) l;
}
}
throw new LinkageError("JCacheJmxSupport not loaded");
} | java | private static JCacheJmxSupport findJCacheJmxSupportInstance() {
for (CacheLifeCycleListener l : CacheManagerImpl.getCacheLifeCycleListeners()) {
if (l instanceof JCacheJmxSupport) {
return (JCacheJmxSupport) l;
}
}
throw new LinkageError("JCacheJmxSupport not loaded");
} | [
"private",
"static",
"JCacheJmxSupport",
"findJCacheJmxSupportInstance",
"(",
")",
"{",
"for",
"(",
"CacheLifeCycleListener",
"l",
":",
"CacheManagerImpl",
".",
"getCacheLifeCycleListeners",
"(",
")",
")",
"{",
"if",
"(",
"l",
"instanceof",
"JCacheJmxSupport",
")",
... | The JMX support is already created via the serviceloader | [
"The",
"JMX",
"support",
"is",
"already",
"created",
"via",
"the",
"serviceloader"
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheManagerAdapter.java#L52-L59 | train |
cache2k/cache2k | cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheManagerAdapter.java | JCacheManagerAdapter.resolveCacheWrapper | public Cache resolveCacheWrapper(org.cache2k.Cache _c2kCache) {
synchronized (getLockObject()) {
return c2k2jCache.get(_c2kCache);
}
} | java | public Cache resolveCacheWrapper(org.cache2k.Cache _c2kCache) {
synchronized (getLockObject()) {
return c2k2jCache.get(_c2kCache);
}
} | [
"public",
"Cache",
"resolveCacheWrapper",
"(",
"org",
".",
"cache2k",
".",
"Cache",
"_c2kCache",
")",
"{",
"synchronized",
"(",
"getLockObject",
"(",
")",
")",
"{",
"return",
"c2k2jCache",
".",
"get",
"(",
"_c2kCache",
")",
";",
"}",
"}"
] | Return the JCache wrapper for a c2k cache. | [
"Return",
"the",
"JCache",
"wrapper",
"for",
"a",
"c2k",
"cache",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheManagerAdapter.java#L302-L306 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/ClockProPlusEviction.java | ClockProPlusEviction.removeFromReplacementList | @Override
protected void removeFromReplacementList(Entry e) {
if (e.isHot()) {
hotHits += e.hitCnt;
handHot = Entry.removeFromCyclicList(handHot, e);
hotSize--;
} else {
coldHits += e.hitCnt;
handCold = Entry.removeFromCyclicList(handCold, e);
coldSize--;
}
} | java | @Override
protected void removeFromReplacementList(Entry e) {
if (e.isHot()) {
hotHits += e.hitCnt;
handHot = Entry.removeFromCyclicList(handHot, e);
hotSize--;
} else {
coldHits += e.hitCnt;
handCold = Entry.removeFromCyclicList(handCold, e);
coldSize--;
}
} | [
"@",
"Override",
"protected",
"void",
"removeFromReplacementList",
"(",
"Entry",
"e",
")",
"{",
"if",
"(",
"e",
".",
"isHot",
"(",
")",
")",
"{",
"hotHits",
"+=",
"e",
".",
"hitCnt",
";",
"handHot",
"=",
"Entry",
".",
"removeFromCyclicList",
"(",
"handHo... | Remove, expire or eviction of an entry happens. Remove the entry from the
replacement list data structure.
<p>Why don't generate ghosts here? If the entry is removed because of
a programmatic remove or expiry we should not occupy any resources.
Removing and expiry may also take place when no eviction is needed at all,... | [
"Remove",
"expire",
"or",
"eviction",
"of",
"an",
"entry",
"happens",
".",
"Remove",
"the",
"entry",
"from",
"the",
"replacement",
"list",
"data",
"structure",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/ClockProPlusEviction.java#L151-L162 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/ClockProPlusEviction.java | ClockProPlusEviction.findEvictionCandidate | @Override
protected Entry findEvictionCandidate(Entry _previous) {
coldRunCnt++;
Entry _hand = handCold;
int _scanCnt = 1;
if (_hand == null) {
_hand = refillFromHot(_hand);
}
if (_hand.hitCnt > 0) {
_hand = refillFromHot(_hand);
do {
_scanCnt++;
coldHits += _... | java | @Override
protected Entry findEvictionCandidate(Entry _previous) {
coldRunCnt++;
Entry _hand = handCold;
int _scanCnt = 1;
if (_hand == null) {
_hand = refillFromHot(_hand);
}
if (_hand.hitCnt > 0) {
_hand = refillFromHot(_hand);
do {
_scanCnt++;
coldHits += _... | [
"@",
"Override",
"protected",
"Entry",
"findEvictionCandidate",
"(",
"Entry",
"_previous",
")",
"{",
"coldRunCnt",
"++",
";",
"Entry",
"_hand",
"=",
"handCold",
";",
"int",
"_scanCnt",
"=",
"1",
";",
"if",
"(",
"_hand",
"==",
"null",
")",
"{",
"_hand",
"... | Runs cold hand an in turn hot hand to find eviction candidate. | [
"Runs",
"cold",
"hand",
"an",
"in",
"turn",
"hot",
"hand",
"to",
"find",
"eviction",
"candidate",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/ClockProPlusEviction.java#L247-L276 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/IntHeapCache.java | IntHeapCache.createHashTable | @Override
public Hash2<Integer, V> createHashTable() {
return new Hash2<Integer, V>(this) {
@Override
protected int modifiedHashCode(final int hc) {
return IntHeapCache.this.modifiedHash(hc);
}
@Override
protected boolean keyObjIsEqual(final Integer key, final Entry e) {
... | java | @Override
public Hash2<Integer, V> createHashTable() {
return new Hash2<Integer, V>(this) {
@Override
protected int modifiedHashCode(final int hc) {
return IntHeapCache.this.modifiedHash(hc);
}
@Override
protected boolean keyObjIsEqual(final Integer key, final Entry e) {
... | [
"@",
"Override",
"public",
"Hash2",
"<",
"Integer",
",",
"V",
">",
"createHashTable",
"(",
")",
"{",
"return",
"new",
"Hash2",
"<",
"Integer",
",",
"V",
">",
"(",
"this",
")",
"{",
"@",
"Override",
"protected",
"int",
"modifiedHashCode",
"(",
"final",
... | Modified hash table implementation. Rehash needs to calculate the correct hash code again. | [
"Modified",
"hash",
"table",
"implementation",
".",
"Rehash",
"needs",
"to",
"calculate",
"the",
"correct",
"hash",
"code",
"again",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/IntHeapCache.java#L58-L71 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/integration/Loaders.java | Loaders.wrapRefreshedTime | @SuppressWarnings("unchecked")
public static <V> LoadDetail<V> wrapRefreshedTime(V value, long refreshedTimeInMillis) {
return new RefreshedTimeWrapper<V>(value, refreshedTimeInMillis);
} | java | @SuppressWarnings("unchecked")
public static <V> LoadDetail<V> wrapRefreshedTime(V value, long refreshedTimeInMillis) {
return new RefreshedTimeWrapper<V>(value, refreshedTimeInMillis);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"V",
">",
"LoadDetail",
"<",
"V",
">",
"wrapRefreshedTime",
"(",
"V",
"value",
",",
"long",
"refreshedTimeInMillis",
")",
"{",
"return",
"new",
"RefreshedTimeWrapper",
"<",
"V",
">",
... | Wraps a loaded value to add the refreshed value.
@see CacheLoader#load(Object)
@see AdvancedCacheLoader#load(Object, long, CacheEntry)
@see FunctionalCacheLoader#load(Object) | [
"Wraps",
"a",
"loaded",
"value",
"to",
"add",
"the",
"refreshed",
"value",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/integration/Loaders.java#L39-L42 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Cache2kCoreProviderImpl.java | Cache2kCoreProviderImpl.registerExtensions | private void registerExtensions() {
Iterator<Cache2kExtensionProvider> it =
ServiceLoader.load(Cache2kExtensionProvider.class, CacheManager.class.getClassLoader()).iterator();
while (it.hasNext()) {
try {
it.next().registerCache2kExtension();
} catch (ServiceConfigurationError ex) {
... | java | private void registerExtensions() {
Iterator<Cache2kExtensionProvider> it =
ServiceLoader.load(Cache2kExtensionProvider.class, CacheManager.class.getClassLoader()).iterator();
while (it.hasNext()) {
try {
it.next().registerCache2kExtension();
} catch (ServiceConfigurationError ex) {
... | [
"private",
"void",
"registerExtensions",
"(",
")",
"{",
"Iterator",
"<",
"Cache2kExtensionProvider",
">",
"it",
"=",
"ServiceLoader",
".",
"load",
"(",
"Cache2kExtensionProvider",
".",
"class",
",",
"CacheManager",
".",
"class",
".",
"getClassLoader",
"(",
")",
... | ignore load errors, so we can remove the serverSide or the xmlConfiguration code
and cache2k core still works | [
"ignore",
"load",
"errors",
"so",
"we",
"can",
"remove",
"the",
"serverSide",
"or",
"the",
"xmlConfiguration",
"code",
"and",
"cache2k",
"core",
"still",
"works"
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Cache2kCoreProviderImpl.java#L74-L84 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/Cache2kCoreProviderImpl.java | Cache2kCoreProviderImpl.removeManager | void removeManager(CacheManager cm) {
synchronized (getLockObject()) {
Map<String, CacheManager> _name2managers = loader2name2manager.get(cm.getClassLoader());
_name2managers = new HashMap<String, CacheManager>(_name2managers);
Object _removed = _name2managers.remove(cm.getName());
Map<Class... | java | void removeManager(CacheManager cm) {
synchronized (getLockObject()) {
Map<String, CacheManager> _name2managers = loader2name2manager.get(cm.getClassLoader());
_name2managers = new HashMap<String, CacheManager>(_name2managers);
Object _removed = _name2managers.remove(cm.getName());
Map<Class... | [
"void",
"removeManager",
"(",
"CacheManager",
"cm",
")",
"{",
"synchronized",
"(",
"getLockObject",
"(",
")",
")",
"{",
"Map",
"<",
"String",
",",
"CacheManager",
">",
"_name2managers",
"=",
"loader2name2manager",
".",
"get",
"(",
"cm",
".",
"getClassLoader",
... | Called from the manager after a close. Removes the manager from the known managers. | [
"Called",
"from",
"the",
"manager",
"after",
"a",
"close",
".",
"Removes",
"the",
"manager",
"from",
"the",
"known",
"managers",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/Cache2kCoreProviderImpl.java#L170-L184 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/WiredCache.java | WiredCache.loadAllWithAsyncLoader | private void loadAllWithAsyncLoader(final CacheOperationCompletionListener _listener, final Set<K> _keysToLoad) {
final AtomicInteger _countDown = new AtomicInteger(_keysToLoad.size());
EntryAction.ActionCompletedCallback cb = new EntryAction.ActionCompletedCallback() {
@Override
public void entryAc... | java | private void loadAllWithAsyncLoader(final CacheOperationCompletionListener _listener, final Set<K> _keysToLoad) {
final AtomicInteger _countDown = new AtomicInteger(_keysToLoad.size());
EntryAction.ActionCompletedCallback cb = new EntryAction.ActionCompletedCallback() {
@Override
public void entryAc... | [
"private",
"void",
"loadAllWithAsyncLoader",
"(",
"final",
"CacheOperationCompletionListener",
"_listener",
",",
"final",
"Set",
"<",
"K",
">",
"_keysToLoad",
")",
"{",
"final",
"AtomicInteger",
"_countDown",
"=",
"new",
"AtomicInteger",
"(",
"_keysToLoad",
".",
"si... | Load the keys into the cache via the async path. The key set must always be non empty.
The completion listener is called when all keys are loaded. | [
"Load",
"the",
"keys",
"into",
"the",
"cache",
"via",
"the",
"async",
"path",
".",
"The",
"key",
"set",
"must",
"always",
"be",
"non",
"empty",
".",
"The",
"completion",
"listener",
"is",
"called",
"when",
"all",
"keys",
"are",
"loaded",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/WiredCache.java#L282-L298 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/WiredCache.java | WiredCache.peekAll | @Override
public Map<K, V> peekAll(final Iterable<? extends K> keys) {
Map<K, CacheEntry<K, V>> map = new HashMap<K, CacheEntry<K, V>>();
for (K k : keys) {
CacheEntry<K, V> e = execute(k, SPEC.peekEntry(k));
if (e != null) {
map.put(k, e);
}
}
return heapCache.convertCacheEn... | java | @Override
public Map<K, V> peekAll(final Iterable<? extends K> keys) {
Map<K, CacheEntry<K, V>> map = new HashMap<K, CacheEntry<K, V>>();
for (K k : keys) {
CacheEntry<K, V> e = execute(k, SPEC.peekEntry(k));
if (e != null) {
map.put(k, e);
}
}
return heapCache.convertCacheEn... | [
"@",
"Override",
"public",
"Map",
"<",
"K",
",",
"V",
">",
"peekAll",
"(",
"final",
"Iterable",
"<",
"?",
"extends",
"K",
">",
"keys",
")",
"{",
"Map",
"<",
"K",
",",
"CacheEntry",
"<",
"K",
",",
"V",
">",
">",
"map",
"=",
"new",
"HashMap",
"<"... | We need to deal with possible null values and exceptions. This is
a simple placeholder implementation that covers it all by working
on the entry. | [
"We",
"need",
"to",
"deal",
"with",
"possible",
"null",
"values",
"and",
"exceptions",
".",
"This",
"is",
"a",
"simple",
"placeholder",
"implementation",
"that",
"covers",
"it",
"all",
"by",
"working",
"on",
"the",
"entry",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/WiredCache.java#L515-L525 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/WiredCache.java | WiredCache.onEvictionFromHeap | @Override
public void onEvictionFromHeap(final Entry<K, V> e) {
CacheEntry<K,V> _currentEntry = heapCache.returnCacheEntry(e);
if (syncEntryEvictedListeners != null) {
for (CacheEntryEvictedListener<K, V> l : syncEntryEvictedListeners) {
l.onEntryEvicted(this, _currentEntry);
}
}
} | java | @Override
public void onEvictionFromHeap(final Entry<K, V> e) {
CacheEntry<K,V> _currentEntry = heapCache.returnCacheEntry(e);
if (syncEntryEvictedListeners != null) {
for (CacheEntryEvictedListener<K, V> l : syncEntryEvictedListeners) {
l.onEntryEvicted(this, _currentEntry);
}
}
} | [
"@",
"Override",
"public",
"void",
"onEvictionFromHeap",
"(",
"final",
"Entry",
"<",
"K",
",",
"V",
">",
"e",
")",
"{",
"CacheEntry",
"<",
"K",
",",
"V",
">",
"_currentEntry",
"=",
"heapCache",
".",
"returnCacheEntry",
"(",
"e",
")",
";",
"if",
"(",
... | Nothing done here. Will notify the storage about eviction in some future version. | [
"Nothing",
"done",
"here",
".",
"Will",
"notify",
"the",
"storage",
"about",
"eviction",
"in",
"some",
"future",
"version",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/WiredCache.java#L667-L675 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/expiry/Expiry.java | Expiry.mixTimeSpanAndPointInTime | public static long mixTimeSpanAndPointInTime(long loadTime, long refreshAfter, long pointInTime) {
long _refreshTime = loadTime + refreshAfter;
if (_refreshTime < 0) {
_refreshTime = ETERNAL;
}
if (pointInTime == ETERNAL) {
return _refreshTime;
}
if (pointInTime > _refreshTime) {
... | java | public static long mixTimeSpanAndPointInTime(long loadTime, long refreshAfter, long pointInTime) {
long _refreshTime = loadTime + refreshAfter;
if (_refreshTime < 0) {
_refreshTime = ETERNAL;
}
if (pointInTime == ETERNAL) {
return _refreshTime;
}
if (pointInTime > _refreshTime) {
... | [
"public",
"static",
"long",
"mixTimeSpanAndPointInTime",
"(",
"long",
"loadTime",
",",
"long",
"refreshAfter",
",",
"long",
"pointInTime",
")",
"{",
"long",
"_refreshTime",
"=",
"loadTime",
"+",
"refreshAfter",
";",
"if",
"(",
"_refreshTime",
"<",
"0",
")",
"{... | Combine a refresh time span and an expiry at a specified point in time.
<p>If the expiry time is far ahead of time the refresh time span takes
precedence. If the point in time is close by this time takes precedence.
If the refresh time is too close to the requested point an earlier refresh
time is used to keep maximum... | [
"Combine",
"a",
"refresh",
"time",
"span",
"and",
"an",
"expiry",
"at",
"a",
"specified",
"point",
"in",
"time",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/expiry/Expiry.java#L98-L118 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/event/AsyncDispatcher.java | AsyncDispatcher.getLockObject | private static Object getLockObject(Object key) {
int hc = key.hashCode();
return KEY_LOCKS[hc & KEY_LOCKS_MASK];
} | java | private static Object getLockObject(Object key) {
int hc = key.hashCode();
return KEY_LOCKS[hc & KEY_LOCKS_MASK];
} | [
"private",
"static",
"Object",
"getLockObject",
"(",
"Object",
"key",
")",
"{",
"int",
"hc",
"=",
"key",
".",
"hashCode",
"(",
")",
";",
"return",
"KEY_LOCKS",
"[",
"hc",
"&",
"KEY_LOCKS_MASK",
"]",
";",
"}"
] | Simulate locking by key, use the hash code to spread and avoid lock contention.
The additional locking we introduce here is currently run synchronously inside the
entry mutation operation. | [
"Simulate",
"locking",
"by",
"key",
"use",
"the",
"hash",
"code",
"to",
"spread",
"and",
"avoid",
"lock",
"contention",
".",
"The",
"additional",
"locking",
"we",
"introduce",
"here",
"is",
"currently",
"run",
"synchronously",
"inside",
"the",
"entry",
"mutati... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/event/AsyncDispatcher.java#L55-L58 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/event/AsyncDispatcher.java | AsyncDispatcher.queue | public void queue(final AsyncEvent<K> _event) {
final K key = _event.getKey();
synchronized (getLockObject(key)) {
Queue<AsyncEvent<K>> q = keyQueue.get(key);
if (q != null) {
q.add(_event);
return;
}
q = new LinkedList<AsyncEvent<K>>();
keyQueue.put(key, q);
}
... | java | public void queue(final AsyncEvent<K> _event) {
final K key = _event.getKey();
synchronized (getLockObject(key)) {
Queue<AsyncEvent<K>> q = keyQueue.get(key);
if (q != null) {
q.add(_event);
return;
}
q = new LinkedList<AsyncEvent<K>>();
keyQueue.put(key, q);
}
... | [
"public",
"void",
"queue",
"(",
"final",
"AsyncEvent",
"<",
"K",
">",
"_event",
")",
"{",
"final",
"K",
"key",
"=",
"_event",
".",
"getKey",
"(",
")",
";",
"synchronized",
"(",
"getLockObject",
"(",
"key",
")",
")",
"{",
"Queue",
"<",
"AsyncEvent",
"... | Immediately executes an event with the provided executor. If an event
is already executing for the identical key, queue the event and execute
the event with FIFO scheme, preserving the order of the arrival. | [
"Immediately",
"executes",
"an",
"event",
"with",
"the",
"provided",
"executor",
".",
"If",
"an",
"event",
"is",
"already",
"executing",
"for",
"the",
"identical",
"key",
"queue",
"the",
"event",
"and",
"execute",
"the",
"event",
"with",
"FIFO",
"scheme",
"p... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/event/AsyncDispatcher.java#L74-L92 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/event/AsyncDispatcher.java | AsyncDispatcher.runMoreOrStop | public void runMoreOrStop(AsyncEvent<K> _event) {
for (;;) {
try {
_event.execute();
} catch (Throwable t) {
cache.getLog().warn("Async event exception", t);
}
final K key = _event.getKey();
synchronized (getLockObject(key)) {
Queue<AsyncEvent<K>> q = keyQueue.g... | java | public void runMoreOrStop(AsyncEvent<K> _event) {
for (;;) {
try {
_event.execute();
} catch (Throwable t) {
cache.getLog().warn("Async event exception", t);
}
final K key = _event.getKey();
synchronized (getLockObject(key)) {
Queue<AsyncEvent<K>> q = keyQueue.g... | [
"public",
"void",
"runMoreOrStop",
"(",
"AsyncEvent",
"<",
"K",
">",
"_event",
")",
"{",
"for",
"(",
";",
";",
")",
"{",
"try",
"{",
"_event",
".",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"cache",
".",
"getLog",
"... | Run as long there is still an event for the key. | [
"Run",
"as",
"long",
"there",
"is",
"still",
"an",
"event",
"for",
"the",
"key",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/event/AsyncDispatcher.java#L97-L114 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/BaseCache.java | BaseCache.keys | @Override
public Iterable<K> keys() {
return new Iterable<K>() {
@Override
public Iterator<K> iterator() {
final Iterator<CacheEntry<K,V>> it = BaseCache.this.iterator();
return new Iterator<K>() {
@Override
public boolean hasNext() {
return it.hasNext()... | java | @Override
public Iterable<K> keys() {
return new Iterable<K>() {
@Override
public Iterator<K> iterator() {
final Iterator<CacheEntry<K,V>> it = BaseCache.this.iterator();
return new Iterator<K>() {
@Override
public boolean hasNext() {
return it.hasNext()... | [
"@",
"Override",
"public",
"Iterable",
"<",
"K",
">",
"keys",
"(",
")",
"{",
"return",
"new",
"Iterable",
"<",
"K",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Iterator",
"<",
"K",
">",
"iterator",
"(",
")",
"{",
"final",
"Iterator",
"<",
"Cach... | Key iteration on top of normal iterator. | [
"Key",
"iteration",
"on",
"top",
"of",
"normal",
"iterator",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/BaseCache.java#L65-L89 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.setCacheConfig | public void setCacheConfig(final Cache2kConfiguration c) {
valueType = c.getValueType();
keyType = c.getKeyType();
if (name != null) {
throw new IllegalStateException("already configured");
}
setName(c.getName());
setFeatureBit(KEEP_AFTER_EXPIRED, c.isKeepDataAfterExpired());
setFeatur... | java | public void setCacheConfig(final Cache2kConfiguration c) {
valueType = c.getValueType();
keyType = c.getKeyType();
if (name != null) {
throw new IllegalStateException("already configured");
}
setName(c.getName());
setFeatureBit(KEEP_AFTER_EXPIRED, c.isKeepDataAfterExpired());
setFeatur... | [
"public",
"void",
"setCacheConfig",
"(",
"final",
"Cache2kConfiguration",
"c",
")",
"{",
"valueType",
"=",
"c",
".",
"getValueType",
"(",
")",
";",
"keyType",
"=",
"c",
".",
"getKeyType",
"(",
")",
";",
"if",
"(",
"name",
"!=",
"null",
")",
"{",
"throw... | called from CacheBuilder | [
"called",
"from",
"CacheBuilder"
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L252-L287 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.setName | public void setName(String n) {
if (n == null) {
n = this.getClass().getSimpleName() + "#" + cacheCnt++;
}
name = n;
} | java | public void setName(String n) {
if (n == null) {
n = this.getClass().getSimpleName() + "#" + cacheCnt++;
}
name = n;
} | [
"public",
"void",
"setName",
"(",
"String",
"n",
")",
"{",
"if",
"(",
"n",
"==",
"null",
")",
"{",
"n",
"=",
"this",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
"+",
"\"#\"",
"+",
"cacheCnt",
"++",
";",
"}",
"name",
"=",
"n",
";"... | Set the name and configure a logging, used within cache construction. | [
"Set",
"the",
"name",
"and",
"configure",
"a",
"logging",
"used",
"within",
"cache",
"construction",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L319-L324 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.returnEntry | protected CacheEntry<K, V> returnEntry(final ExaminationEntry<K, V> e) {
if (e == null) {
return null;
}
return returnCacheEntry(e);
} | java | protected CacheEntry<K, V> returnEntry(final ExaminationEntry<K, V> e) {
if (e == null) {
return null;
}
return returnCacheEntry(e);
} | [
"protected",
"CacheEntry",
"<",
"K",
",",
"V",
">",
"returnEntry",
"(",
"final",
"ExaminationEntry",
"<",
"K",
",",
"V",
">",
"e",
")",
"{",
"if",
"(",
"e",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"returnCacheEntry",
"(",
"e",
... | Wrap entry in a separate object instance. We can return the entry directly, however we lock on
the entry object. | [
"Wrap",
"entry",
"in",
"a",
"separate",
"object",
"instance",
".",
"We",
"can",
"return",
"the",
"entry",
"directly",
"however",
"we",
"lock",
"on",
"the",
"entry",
"object",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L556-L561 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.putValue | protected final void putValue(final Entry e, final V _value) {
if (!isUpdateTimeNeeded()) {
insertOrUpdateAndCalculateExpiry(e, _value, 0, 0, 0 , INSERT_STAT_PUT);
} else {
long t = clock.millis();
insertOrUpdateAndCalculateExpiry(e, _value, t, t, t, INSERT_STAT_PUT);
}
} | java | protected final void putValue(final Entry e, final V _value) {
if (!isUpdateTimeNeeded()) {
insertOrUpdateAndCalculateExpiry(e, _value, 0, 0, 0 , INSERT_STAT_PUT);
} else {
long t = clock.millis();
insertOrUpdateAndCalculateExpiry(e, _value, t, t, t, INSERT_STAT_PUT);
}
} | [
"protected",
"final",
"void",
"putValue",
"(",
"final",
"Entry",
"e",
",",
"final",
"V",
"_value",
")",
"{",
"if",
"(",
"!",
"isUpdateTimeNeeded",
"(",
")",
")",
"{",
"insertOrUpdateAndCalculateExpiry",
"(",
"e",
",",
"_value",
",",
"0",
",",
"0",
",",
... | Update the value directly within entry lock. Since we did not start
entry processing we do not need to notify any waiting threads. | [
"Update",
"the",
"value",
"directly",
"within",
"entry",
"lock",
".",
"Since",
"we",
"did",
"not",
"start",
"entry",
"processing",
"we",
"do",
"not",
"need",
"to",
"notify",
"any",
"waiting",
"threads",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L764-L771 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.replace | protected boolean replace(final K key, final boolean _compare, final V _oldValue, final V _newValue) {
Entry e = lookupEntry(key);
if (e == null) {
metrics.peekMiss();
return false;
}
synchronized (e) {
e.waitForProcessing();
if (e.isGone() || !e.hasFreshData(clock)) {
re... | java | protected boolean replace(final K key, final boolean _compare, final V _oldValue, final V _newValue) {
Entry e = lookupEntry(key);
if (e == null) {
metrics.peekMiss();
return false;
}
synchronized (e) {
e.waitForProcessing();
if (e.isGone() || !e.hasFreshData(clock)) {
re... | [
"protected",
"boolean",
"replace",
"(",
"final",
"K",
"key",
",",
"final",
"boolean",
"_compare",
",",
"final",
"V",
"_oldValue",
",",
"final",
"V",
"_newValue",
")",
"{",
"Entry",
"e",
"=",
"lookupEntry",
"(",
"key",
")",
";",
"if",
"(",
"e",
"==",
... | replace if value matches. if value not matches, return the existing entry or the dummy entry. | [
"replace",
"if",
"value",
"matches",
".",
"if",
"value",
"not",
"matches",
"return",
"the",
"existing",
"entry",
"or",
"the",
"dummy",
"entry",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L786-L803 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.peekEntryInternal | final protected Entry<K, V> peekEntryInternal(K key) {
int hc = modifiedHash(key.hashCode());
return peekEntryInternal(key, hc, extractIntKeyValue(key, hc));
} | java | final protected Entry<K, V> peekEntryInternal(K key) {
int hc = modifiedHash(key.hashCode());
return peekEntryInternal(key, hc, extractIntKeyValue(key, hc));
} | [
"final",
"protected",
"Entry",
"<",
"K",
",",
"V",
">",
"peekEntryInternal",
"(",
"K",
"key",
")",
"{",
"int",
"hc",
"=",
"modifiedHash",
"(",
"key",
".",
"hashCode",
"(",
")",
")",
";",
"return",
"peekEntryInternal",
"(",
"key",
",",
"hc",
",",
"ext... | Return the entry, if it is in the cache, without invoking the
cache source.
<p>The cache storage is asked whether the entry is present.
If the entry is not present, this result is cached in the local
cache. | [
"Return",
"the",
"entry",
"if",
"it",
"is",
"in",
"the",
"cache",
"without",
"invoking",
"the",
"cache",
"source",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L813-L816 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.removeIfEquals | @Override
public boolean removeIfEquals(K key, V _value) {
Entry e = lookupEntry(key);
if (e == null) {
metrics.peekMiss();
return false;
}
synchronized (e) {
e.waitForProcessing();
if (e.isGone()) {
metrics.peekMiss();
return false;
}
boolean f = e.... | java | @Override
public boolean removeIfEquals(K key, V _value) {
Entry e = lookupEntry(key);
if (e == null) {
metrics.peekMiss();
return false;
}
synchronized (e) {
e.waitForProcessing();
if (e.isGone()) {
metrics.peekMiss();
return false;
}
boolean f = e.... | [
"@",
"Override",
"public",
"boolean",
"removeIfEquals",
"(",
"K",
"key",
",",
"V",
"_value",
")",
"{",
"Entry",
"e",
"=",
"lookupEntry",
"(",
"key",
")",
";",
"if",
"(",
"e",
"==",
"null",
")",
"{",
"metrics",
".",
"peekMiss",
"(",
")",
";",
"retur... | Remove the object from the cache. | [
"Remove",
"the",
"object",
"from",
"the",
"cache",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L968-L993 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.loadAndReplace | protected void loadAndReplace(K key) {
Entry e;
for (;;) {
e = lookupOrNewEntry(key);
synchronized (e) {
e.waitForProcessing();
if (e.isGone()) {
metrics.goneSpin();
continue;
}
e.startProcessing(Entry.ProcessingState.LOAD);
break;
}
... | java | protected void loadAndReplace(K key) {
Entry e;
for (;;) {
e = lookupOrNewEntry(key);
synchronized (e) {
e.waitForProcessing();
if (e.isGone()) {
metrics.goneSpin();
continue;
}
e.startProcessing(Entry.ProcessingState.LOAD);
break;
}
... | [
"protected",
"void",
"loadAndReplace",
"(",
"K",
"key",
")",
"{",
"Entry",
"e",
";",
"for",
"(",
";",
";",
")",
"{",
"e",
"=",
"lookupOrNewEntry",
"(",
"key",
")",
";",
"synchronized",
"(",
"e",
")",
"{",
"e",
".",
"waitForProcessing",
"(",
")",
";... | Always fetch the value from the source. That is a copy of getEntryInternal
without freshness checks. | [
"Always",
"fetch",
"the",
"value",
"from",
"the",
"source",
".",
"That",
"is",
"a",
"copy",
"of",
"getEntryInternal",
"without",
"freshness",
"checks",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L1198-L1219 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.checkForHashCodeChange | private void checkForHashCodeChange(Entry<K, V> e) {
K key = extractKeyObj(e);
if (extractIntKeyValue(key, modifiedHash(key.hashCode())) != e.hashCode) {
if (keyMutationCnt == 0) {
getLog().warn("Key mismatch! Key hashcode changed! keyClass=" + e.getKey().getClass().getName());
String s;
... | java | private void checkForHashCodeChange(Entry<K, V> e) {
K key = extractKeyObj(e);
if (extractIntKeyValue(key, modifiedHash(key.hashCode())) != e.hashCode) {
if (keyMutationCnt == 0) {
getLog().warn("Key mismatch! Key hashcode changed! keyClass=" + e.getKey().getClass().getName());
String s;
... | [
"private",
"void",
"checkForHashCodeChange",
"(",
"Entry",
"<",
"K",
",",
"V",
">",
"e",
")",
"{",
"K",
"key",
"=",
"extractKeyObj",
"(",
"e",
")",
";",
"if",
"(",
"extractIntKeyValue",
"(",
"key",
",",
"modifiedHash",
"(",
"key",
".",
"hashCode",
"(",... | Check whether the key was modified during the stay of the entry in the cache.
We only need to check this when the entry is removed, since we expect that if
the key has changed, the stored hash code in the cache will not match any more and
the item is evicted very fast. | [
"Check",
"whether",
"the",
"key",
"was",
"modified",
"during",
"the",
"stay",
"of",
"the",
"entry",
"in",
"the",
"cache",
".",
"We",
"only",
"need",
"to",
"check",
"this",
"when",
"the",
"entry",
"is",
"removed",
"since",
"we",
"expect",
"that",
"if",
... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L1335-L1352 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.entryInRefreshProbationAccessed | private boolean entryInRefreshProbationAccessed(final Entry<K, V> e, final long now) {
long nrt = e.getRefreshProbationNextRefreshTime();
if (nrt > now) {
reviveRefreshedEntry(e, nrt);
return true;
}
return false;
} | java | private boolean entryInRefreshProbationAccessed(final Entry<K, V> e, final long now) {
long nrt = e.getRefreshProbationNextRefreshTime();
if (nrt > now) {
reviveRefreshedEntry(e, nrt);
return true;
}
return false;
} | [
"private",
"boolean",
"entryInRefreshProbationAccessed",
"(",
"final",
"Entry",
"<",
"K",
",",
"V",
">",
"e",
",",
"final",
"long",
"now",
")",
"{",
"long",
"nrt",
"=",
"e",
".",
"getRefreshProbationNextRefreshTime",
"(",
")",
";",
"if",
"(",
"nrt",
">",
... | Entry was refreshed before, reset timer and make entry visible again. | [
"Entry",
"was",
"refreshed",
"before",
"reset",
"timer",
"and",
"make",
"entry",
"visible",
"again",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L1393-L1400 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.resiliencePolicyException | private void resiliencePolicyException(final Entry<K, V> e, final long t0, final long t, Throwable _exception) {
ExceptionWrapper<K> _value = new ExceptionWrapper(extractKeyObj(e), _exception, t0, e);
insert(e, (V) _value, t0, t, t0, INSERT_STAT_LOAD, 0);
} | java | private void resiliencePolicyException(final Entry<K, V> e, final long t0, final long t, Throwable _exception) {
ExceptionWrapper<K> _value = new ExceptionWrapper(extractKeyObj(e), _exception, t0, e);
insert(e, (V) _value, t0, t, t0, INSERT_STAT_LOAD, 0);
} | [
"private",
"void",
"resiliencePolicyException",
"(",
"final",
"Entry",
"<",
"K",
",",
"V",
">",
"e",
",",
"final",
"long",
"t0",
",",
"final",
"long",
"t",
",",
"Throwable",
"_exception",
")",
"{",
"ExceptionWrapper",
"<",
"K",
">",
"_value",
"=",
"new",... | Exception from the resilience policy. We have two exceptions now. One from the loader or the expiry policy,
one from the resilience policy. We propagate the more severe one from the resilience policy. | [
"Exception",
"from",
"the",
"resilience",
"policy",
".",
"We",
"have",
"two",
"exceptions",
"now",
".",
"One",
"from",
"the",
"loader",
"or",
"the",
"expiry",
"policy",
"one",
"from",
"the",
"resilience",
"policy",
".",
"We",
"propagate",
"the",
"more",
"s... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L1445-L1448 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.refreshEntry | private void refreshEntry(final Entry<K, V> e) {
synchronized (e) {
e.waitForProcessing();
if (e.isGone()) {
return;
}
e.startProcessing(Entry.ProcessingState.REFRESH);
}
boolean _finished = false;
try {
load(e);
_finished = true;
} catch (CacheClosedExcep... | java | private void refreshEntry(final Entry<K, V> e) {
synchronized (e) {
e.waitForProcessing();
if (e.isGone()) {
return;
}
e.startProcessing(Entry.ProcessingState.REFRESH);
}
boolean _finished = false;
try {
load(e);
_finished = true;
} catch (CacheClosedExcep... | [
"private",
"void",
"refreshEntry",
"(",
"final",
"Entry",
"<",
"K",
",",
"V",
">",
"e",
")",
"{",
"synchronized",
"(",
"e",
")",
"{",
"e",
".",
"waitForProcessing",
"(",
")",
";",
"if",
"(",
"e",
".",
"isGone",
"(",
")",
")",
"{",
"return",
";",
... | Executed in loader thread. Load the entry again. After the load we copy the entry to the
refresh hash and expire it in the main hash. The entry needs to stay in the main hash
during the load, to block out concurrent reads. | [
"Executed",
"in",
"loader",
"thread",
".",
"Load",
"the",
"entry",
"again",
".",
"After",
"the",
"load",
"we",
"copy",
"the",
"entry",
"to",
"the",
"refresh",
"hash",
"and",
"expire",
"it",
"in",
"the",
"main",
"hash",
".",
"The",
"entry",
"needs",
"to... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L1565-L1589 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.expireAndRemoveEventually | private void expireAndRemoveEventually(final Entry e) {
if (isKeepAfterExpired() || e.isProcessing()) {
metrics.expiredKept();
} else {
removeEntry(e);
}
} | java | private void expireAndRemoveEventually(final Entry e) {
if (isKeepAfterExpired() || e.isProcessing()) {
metrics.expiredKept();
} else {
removeEntry(e);
}
} | [
"private",
"void",
"expireAndRemoveEventually",
"(",
"final",
"Entry",
"e",
")",
"{",
"if",
"(",
"isKeepAfterExpired",
"(",
")",
"||",
"e",
".",
"isProcessing",
"(",
")",
")",
"{",
"metrics",
".",
"expiredKept",
"(",
")",
";",
"}",
"else",
"{",
"removeEn... | Remove expired from heap and increment statistics. The entry is not removed when
there is processing going on in parallel.
@see #expireAndRemoveEventuallyAfterProcessing(Entry) | [
"Remove",
"expired",
"from",
"heap",
"and",
"increment",
"statistics",
".",
"The",
"entry",
"is",
"not",
"removed",
"when",
"there",
"is",
"processing",
"going",
"on",
"in",
"parallel",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L1656-L1663 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.getAll | public Map<K, V> getAll(final Iterable<? extends K> _inputKeys) {
Map<K, ExaminationEntry<K, V>> map = new HashMap<K, ExaminationEntry<K, V>>();
for (K k : _inputKeys) {
Entry<K,V> e = getEntryInternal(k);
if (e != null) {
map.put(extractKeyObj(e), ReadOnlyCacheEntry.of(e));
}
}
... | java | public Map<K, V> getAll(final Iterable<? extends K> _inputKeys) {
Map<K, ExaminationEntry<K, V>> map = new HashMap<K, ExaminationEntry<K, V>>();
for (K k : _inputKeys) {
Entry<K,V> e = getEntryInternal(k);
if (e != null) {
map.put(extractKeyObj(e), ReadOnlyCacheEntry.of(e));
}
}
... | [
"public",
"Map",
"<",
"K",
",",
"V",
">",
"getAll",
"(",
"final",
"Iterable",
"<",
"?",
"extends",
"K",
">",
"_inputKeys",
")",
"{",
"Map",
"<",
"K",
",",
"ExaminationEntry",
"<",
"K",
",",
"V",
">",
">",
"map",
"=",
"new",
"HashMap",
"<",
"K",
... | JSR107 bulk interface. The behaviour is compatible to the JSR107 TCK. We also need
to be compatible to the exception handling policy, which says that the exception
is to be thrown when most specific. So exceptions are only thrown, when the value
which has produced an exception is requested from the map. | [
"JSR107",
"bulk",
"interface",
".",
"The",
"behaviour",
"is",
"compatible",
"to",
"the",
"JSR107",
"TCK",
".",
"We",
"also",
"need",
"to",
"be",
"compatible",
"to",
"the",
"exception",
"handling",
"policy",
"which",
"says",
"that",
"the",
"exception",
"is",
... | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L1693-L1702 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/HeapCache.java | HeapCache.checkIntegrity | public final void checkIntegrity() {
executeWithGlobalLock(new Job<Void>() {
@Override
public Void call() {
IntegrityState is = getIntegrityState();
if (is.getStateFlags() > 0) {
throw new Error(
"cache2k integrity error: " +
is.getStateDescriptor() + ",... | java | public final void checkIntegrity() {
executeWithGlobalLock(new Job<Void>() {
@Override
public Void call() {
IntegrityState is = getIntegrityState();
if (is.getStateFlags() > 0) {
throw new Error(
"cache2k integrity error: " +
is.getStateDescriptor() + ",... | [
"public",
"final",
"void",
"checkIntegrity",
"(",
")",
"{",
"executeWithGlobalLock",
"(",
"new",
"Job",
"<",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
")",
"{",
"IntegrityState",
"is",
"=",
"getIntegrityState",
"(",
")",
... | Check internal data structures and throw and exception if something is wrong, used for unit testing | [
"Check",
"internal",
"data",
"structures",
"and",
"throw",
"and",
"exception",
"if",
"something",
"is",
"wrong",
"used",
"for",
"unit",
"testing"
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/HeapCache.java#L1802-L1815 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/configuration/DefaultCustomizationCollection.java | DefaultCustomizationCollection.add | @Override
public boolean add(final CustomizationSupplier<T> entry) {
if (list.contains(entry)) {
throw new IllegalArgumentException("duplicate entry");
}
return list.add(entry);
} | java | @Override
public boolean add(final CustomizationSupplier<T> entry) {
if (list.contains(entry)) {
throw new IllegalArgumentException("duplicate entry");
}
return list.add(entry);
} | [
"@",
"Override",
"public",
"boolean",
"add",
"(",
"final",
"CustomizationSupplier",
"<",
"T",
">",
"entry",
")",
"{",
"if",
"(",
"list",
".",
"contains",
"(",
"entry",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"duplicate entry\"",
")"... | Adds a customization to the collection.
@return always {@code true}
@throws IllegalArgumentException if the entry is already existing. | [
"Adds",
"a",
"customization",
"to",
"the",
"collection",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/configuration/DefaultCustomizationCollection.java#L59-L65 | train |
cache2k/cache2k | cache2k-core/src/main/java/org/cache2k/core/concurrency/Locks.java | Locks.newOptimistic | public static OptimisticLock newOptimistic() {
if (optimisticLockImplementation == null) {
initializeOptimisticLock();
}
try {
return optimisticLockImplementation.newInstance();
} catch (Exception ex) {
throw new Error(ex);
}
} | java | public static OptimisticLock newOptimistic() {
if (optimisticLockImplementation == null) {
initializeOptimisticLock();
}
try {
return optimisticLockImplementation.newInstance();
} catch (Exception ex) {
throw new Error(ex);
}
} | [
"public",
"static",
"OptimisticLock",
"newOptimistic",
"(",
")",
"{",
"if",
"(",
"optimisticLockImplementation",
"==",
"null",
")",
"{",
"initializeOptimisticLock",
"(",
")",
";",
"}",
"try",
"{",
"return",
"optimisticLockImplementation",
".",
"newInstance",
"(",
... | Returns a new lock implementation depending on the platform support. | [
"Returns",
"a",
"new",
"lock",
"implementation",
"depending",
"on",
"the",
"platform",
"support",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-core/src/main/java/org/cache2k/core/concurrency/Locks.java#L37-L46 | train |
cache2k/cache2k | cache2k-jcache/src/main/java/org/cache2k/jcache/provider/TouchyJCacheAdapter.java | TouchyJCacheAdapter.returnEntry | private Entry<K, V> returnEntry(final Entry<K, V> e) {
touchEntry(e.getKey());
return e;
} | java | private Entry<K, V> returnEntry(final Entry<K, V> e) {
touchEntry(e.getKey());
return e;
} | [
"private",
"Entry",
"<",
"K",
",",
"V",
">",
"returnEntry",
"(",
"final",
"Entry",
"<",
"K",
",",
"V",
">",
"e",
")",
"{",
"touchEntry",
"(",
"e",
".",
"getKey",
"(",
")",
")",
";",
"return",
"e",
";",
"}"
] | Entry is accessed update expiry if needed. | [
"Entry",
"is",
"accessed",
"update",
"expiry",
"if",
"needed",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-jcache/src/main/java/org/cache2k/jcache/provider/TouchyJCacheAdapter.java#L499-L502 | train |
cache2k/cache2k | cache2k-jcache/src/main/java/org/cache2k/jcache/provider/TouchyJCacheAdapter.java | TouchyJCacheAdapter.returnValue | private V returnValue(K key, V _value) {
if (_value != null) {
Duration d = expiryPolicy.getExpiryForAccess();
if (d != null) {
c2kCache.expireAt(key, calculateExpiry(d));
}
return _value;
}
return null;
} | java | private V returnValue(K key, V _value) {
if (_value != null) {
Duration d = expiryPolicy.getExpiryForAccess();
if (d != null) {
c2kCache.expireAt(key, calculateExpiry(d));
}
return _value;
}
return null;
} | [
"private",
"V",
"returnValue",
"(",
"K",
"key",
",",
"V",
"_value",
")",
"{",
"if",
"(",
"_value",
"!=",
"null",
")",
"{",
"Duration",
"d",
"=",
"expiryPolicy",
".",
"getExpiryForAccess",
"(",
")",
";",
"if",
"(",
"d",
"!=",
"null",
")",
"{",
"c2kC... | Entry was accessed update expiry if value is non null. | [
"Entry",
"was",
"accessed",
"update",
"expiry",
"if",
"value",
"is",
"non",
"null",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-jcache/src/main/java/org/cache2k/jcache/provider/TouchyJCacheAdapter.java#L507-L516 | train |
cache2k/cache2k | cache2k-api/src/main/java/org/cache2k/integration/CacheLoader.java | CacheLoader.loadAll | public Map<K, V> loadAll(Iterable<? extends K> keys, Executor executor) throws Exception {
throw new UnsupportedOperationException();
} | java | public Map<K, V> loadAll(Iterable<? extends K> keys, Executor executor) throws Exception {
throw new UnsupportedOperationException();
} | [
"public",
"Map",
"<",
"K",
",",
"V",
">",
"loadAll",
"(",
"Iterable",
"<",
"?",
"extends",
"K",
">",
"keys",
",",
"Executor",
"executor",
")",
"throws",
"Exception",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}"
] | Loads multiple values to the cache.
<p>From inside this method it is illegal to call methods on the same cache. This
may cause a deadlock.
<p>The method is provided to complete the API. At the moment cache2k is not
using it. Please see the road map.
@param keys set of keys for the values to be loaded
@param executor... | [
"Loads",
"multiple",
"values",
"to",
"the",
"cache",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-api/src/main/java/org/cache2k/integration/CacheLoader.java#L107-L109 | train |
cache2k/cache2k | cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheBuilder.java | JCacheBuilder.setupTypes | private void setupTypes() {
if (!cache2kConfigurationWasProvided) {
cache2kConfiguration.setKeyType(config.getKeyType());
cache2kConfiguration.setValueType(config.getValueType());
} else {
if (cache2kConfiguration.getKeyType() == null) {
cache2kConfiguration.setKeyType(config.getKeyTyp... | java | private void setupTypes() {
if (!cache2kConfigurationWasProvided) {
cache2kConfiguration.setKeyType(config.getKeyType());
cache2kConfiguration.setValueType(config.getValueType());
} else {
if (cache2kConfiguration.getKeyType() == null) {
cache2kConfiguration.setKeyType(config.getKeyTyp... | [
"private",
"void",
"setupTypes",
"(",
")",
"{",
"if",
"(",
"!",
"cache2kConfigurationWasProvided",
")",
"{",
"cache2kConfiguration",
".",
"setKeyType",
"(",
"config",
".",
"getKeyType",
"(",
")",
")",
";",
"cache2kConfiguration",
".",
"setValueType",
"(",
"confi... | If there is a cache2k configuration, we take the types from there. | [
"If",
"there",
"is",
"a",
"cache2k",
"configuration",
"we",
"take",
"the",
"types",
"from",
"there",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheBuilder.java#L154-L174 | train |
cache2k/cache2k | cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheBuilder.java | JCacheBuilder.setupExceptionPropagator | private void setupExceptionPropagator() {
if (cache2kConfiguration.getExceptionPropagator() != null) {
return;
}
cache2kConfiguration.setExceptionPropagator(
new CustomizationReferenceSupplier<ExceptionPropagator<K>>(new ExceptionPropagator<K>() {
@Override
public RuntimeException pr... | java | private void setupExceptionPropagator() {
if (cache2kConfiguration.getExceptionPropagator() != null) {
return;
}
cache2kConfiguration.setExceptionPropagator(
new CustomizationReferenceSupplier<ExceptionPropagator<K>>(new ExceptionPropagator<K>() {
@Override
public RuntimeException pr... | [
"private",
"void",
"setupExceptionPropagator",
"(",
")",
"{",
"if",
"(",
"cache2kConfiguration",
".",
"getExceptionPropagator",
"(",
")",
"!=",
"null",
")",
"{",
"return",
";",
"}",
"cache2kConfiguration",
".",
"setExceptionPropagator",
"(",
"new",
"CustomizationRef... | If an exception propagator is configured, take this one, otherwise go with default that
is providing JCache compatible behavior. | [
"If",
"an",
"exception",
"propagator",
"is",
"configured",
"take",
"this",
"one",
"otherwise",
"go",
"with",
"default",
"that",
"is",
"providing",
"JCache",
"compatible",
"behavior",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheBuilder.java#L190-L201 | train |
cache2k/cache2k | cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheBuilder.java | JCacheBuilder.setupCacheThrough | private void setupCacheThrough() {
if (config.getCacheLoaderFactory() != null) {
final CacheLoader<K, V> clf = config.getCacheLoaderFactory().create();
cache2kConfiguration.setAdvancedLoader(
new CustomizationReferenceSupplier<AdvancedCacheLoader<K, V>>(
new CloseableLoader() {
... | java | private void setupCacheThrough() {
if (config.getCacheLoaderFactory() != null) {
final CacheLoader<K, V> clf = config.getCacheLoaderFactory().create();
cache2kConfiguration.setAdvancedLoader(
new CustomizationReferenceSupplier<AdvancedCacheLoader<K, V>>(
new CloseableLoader() {
... | [
"private",
"void",
"setupCacheThrough",
"(",
")",
"{",
"if",
"(",
"config",
".",
"getCacheLoaderFactory",
"(",
")",
"!=",
"null",
")",
"{",
"final",
"CacheLoader",
"<",
"K",
",",
"V",
">",
"clf",
"=",
"config",
".",
"getCacheLoaderFactory",
"(",
")",
"."... | Configure loader and writer. | [
"Configure",
"loader",
"and",
"writer",
"."
] | 3c9ccff12608c598c387ec50957089784cc4b618 | https://github.com/cache2k/cache2k/blob/3c9ccff12608c598c387ec50957089784cc4b618/cache2k-jcache/src/main/java/org/cache2k/jcache/provider/JCacheBuilder.java#L209-L267 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.