Cache.ValueRetrievalException, Cache.ValueWrapper
コンストラクターと説明 |
---|
NoOpCache(java.lang.String name) 指定された名前で NoOpCache インスタンスを作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
void | clear() キャッシュからすべてのマッピングを削除します。 |
void | evict(java.lang.Object key) このキーが存在する場合、このキャッシュからこのキーのマッピングを削除します。 |
Cache.ValueWrapper | get(java.lang.Object key) このキャッシュが指定されたキーをマップする値を返します。 |
<T> T | get(java.lang.Object key, java.util.concurrent.Callable<T> valueLoader) このキャッシュが指定されたキーをマップする値を返し、必要に応じて valueLoader からその値を取得します。 |
<T> T | get(java.lang.Object key, java.lang.Class<T> type) このキャッシュが指定されたキーをマップする値を返します。一般的に、戻り値がキャストされる型を指定します。 |
java.lang.String | getName() キャッシュ名を返します。 |
java.lang.Object | getNativeCache() 基になるネイティブキャッシュプロバイダーを返します。 |
void | put(java.lang.Object key, java.lang.Object value) 指定された値をこのキャッシュ内の指定されたキーに関連付けます。 |
Cache.ValueWrapper | putIfAbsent(java.lang.Object key, java.lang.Object value) 指定された値が設定されていない場合、指定された値をこのキャッシュ内の指定されたキーと原子的に関連付けます。 |
public NoOpCache(java.lang.String name)
NoOpCache
インスタンスを作成します。name
- キャッシュの名前 public java.lang.String getName()
Cache
public java.lang.Object getNativeCache()
Cache
Cache
の getNativeCache
@Nullable public Cache.ValueWrapper get(java.lang.Object key)
Cache
キャッシュにこのキーのマッピングが含まれていない場合は、null
を返します。そうでない場合、キャッシュされた値(null
自体である可能性があります)が Cache.ValueWrapper
で返されます。
Cache
の get
key
- 関連する値が返されるキー Cache.ValueWrapper
内に含まれ、キャッシュされた null
値も保持する場合があります。返されるストレート null
は、キャッシュにこのキーのマッピングが含まれていないことを意味します。Cache.get(Object, Class)
@Nullable public <T> T get(java.lang.Object key, @Nullable java.lang.Class<T> type)
Cache
メモ: この get
のバリアントでは、キャッシュされた null
値とキャッシュエントリがまったく見つからないことを区別できません。代わりに、その目的のために標準の Cache.get(Object)
バリアントを使用してください。
Cache
の get
key
- 関連する値が返されるキー type
- 戻り値の必要な型 (型チェックをバイパスする null
の場合があります。キャッシュで null
値が見つかった場合、指定された型は無関係です)null
自体である場合があります)をマップする値、またはキャッシュにこのキーのマッピングが含まれていない場合は null
Cache.get(Object)
@Nullable public <T> T get(java.lang.Object key, java.util.concurrent.Callable<T> valueLoader)
Cache
valueLoader
からその値を取得します。このメソッドは、従来の「キャッシュされている場合は返す、そうでない場合は作成、キャッシュして返す」パターンの単純な代替を提供します。 可能な場合、実装は、同じキーへの同時アクセスの場合に指定された valueLoader
が 1 回だけ呼び出されるように、ロード操作が同期されることを確認する必要があります。
valueLoader
が例外をスローした場合、Cache.ValueRetrievalException
にラップされます
public void put(java.lang.Object key, @Nullable java.lang.Object value)
Cache
キャッシュに以前にこのキーのマッピングが含まれていた場合、古い値は指定された値に置き換えられます。
@Nullable public Cache.ValueWrapper putIfAbsent(java.lang.Object key, @Nullable java.lang.Object value)
Cache
これは次と同等です:
Object existingValue = cache.get(key);
if (existingValue == null) {
cache.put(key, value);
return null;
} else {
return existingValue;
}
ただし、アクションはアトミックに実行されます。すべての初期状態の CacheManager
実装は、put をアトミックに実行することができるが、オペレーションは、たとえば、非アトミックな方法で、存在のチェックと後続の put との 2 つのステップで実装することもできます。詳細については、使用しているネイティブキャッシュ実装のドキュメントを参照してください。Cache
の putIfAbsent
key
- 指定された値が関連付けられるキー value
- 指定されたキーに関連付けられる値 null
自体の場合もある)をマップする値、またはこの呼び出しの前にキャッシュにそのキーのマッピングが含まれていなかった場合は null
したがって、null
を返すことは、指定された value
がキーに関連付けられていることを示すインジケーターです。public void evict(java.lang.Object key)
Cache