Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / memcache / MemcacheServiceFactory.java
blobe56aab0f8ed0699f877b420b3171bc6c87fe9369
1 // Copyright 2007 Google Inc. All rights reserved.
3 package com.google.appengine.api.memcache;
5 import com.google.appengine.spi.ServiceFactoryFactory;
7 /**
8 * The factory by which users acquire a handle to the MemcacheService.
11 public class MemcacheServiceFactory {
12 /**
13 * Gets a handle to the cache service. Although there is only one actual
14 * cache, an application may make as many {@code MemcacheService} instances
15 * as it finds convenient.
16 * <p>
17 * If using multiple instances, note that the error handler established with
18 * {@link MemcacheService#setErrorHandler(ErrorHandler)} is specific to each
19 * instance.
21 * All operations in the {@code MemcacheService} will use the current
22 * namespace provided by
23 * {@link com.google.appengine.api.NamespaceManager#get()}.
25 * @return a new {@code MemcacheService} instance.
27 public static MemcacheService getMemcacheService() {
28 return getMemcacheService(null);
31 /**
32 * Gets a handle to the cache service, forcing use of specific namespace.
33 * The method returns {@code MemcacheService}
34 * similar to the one returned by
35 * {@link MemcacheServiceFactory#getMemcacheService()}
36 * but it will use specified {@code namespace} for all operations.
38 * @param namespace if not {@code null} forces the use of {@code namespace}
39 * for all operations in {@code MemcacheService} . If {@code namespace} is
40 * {@code null} - created {@MemcacheService} will use current namespace
41 * provided by {@link com.google.appengine.api.NamespaceManager#get()}.
43 * @return a new {@code MemcacheService} instance.
45 public static MemcacheService getMemcacheService(String namespace) {
46 return getFactory().getMemcacheService(namespace);
49 /**
50 * Similar to {@link #getMemcacheService()} but returns a handle to an
51 * asynchronous version of the cache service.
53 public static AsyncMemcacheService getAsyncMemcacheService() {
54 return getAsyncMemcacheService(null);
57 /**
58 * Similar to {@link #getMemcacheService(String)} but returns a handle to an
59 * asynchronous version of the cache service.
61 public static AsyncMemcacheService getAsyncMemcacheService(String namespace) {
62 return getFactory().getAsyncMemcacheService(namespace);
65 private MemcacheServiceFactory() {
68 private static IMemcacheServiceFactory getFactory() {
69 return ServiceFactoryFactory.getFactory(IMemcacheServiceFactory.class);