dafabet手机版登录 3.5 DocumentationCURRENT

  1

  The static method returns a new instance.

  2

  Use the builder to define a with alias "preConfigured". This cache will be created when is invoked on the actual instance.

  The first argument is the cache alias, which is used to retrieve the cache from the .

  The second argument, , is used to configure the .

  We use the static method on to create a default configuration.

  3

  Finally, invoking returns a fully instantiated, but uninitialized, we can use.

  4

  Before using the it needs to be initialized, which can be done in 1 of 2 ways:

  Calling on the instance, or calling the method with the boolean parameter set to true.

  5

  A cache is retrieved by passing its alias, key type and value type to the .

  For instance, to obtain the cache declared in step 2 you need its , and .

  For type-safety, we ask for both key and value types to be passed in.

  If these differ from the ones we expect, the throws a early in the application’s lifecycle.

  This guards the from being polluted by random types.

  6

  The can be used to create new instances as needed. Just as in step 2, it requires passing in an

  alias as well as a . The instantiated and fully initialized added will be returned and/or

  accessed through the API.

  7

  The newly added can now be used to store entries, which are comprised of key value pairs.

  The put method’s first parameter is the key and the second parameter is the value.

  Remember the key and value types must be the same types as those defined in the .

  Additionally the key must be unique and is only associated with one value.

  8

  A value is retrieved from a cache by calling the method.

  It only takes one parameter which is the key, and returns the value associated with that key. If there is no value associated with that key then null is returned.

  9

  We can a given . The will not only remove its reference to the

  , but will also close it. The releases all locally held transient resources (such as memory).

  References to this become unusable.

  10

  In order to release all transient resources (memory, threads, …?) a provides to instances

  it manages, you have to invoke , which in turns closes all instances known at the time.

  文字到来源:http://www.ehcache.org/documentation/3.5/getting-started.html