當前位置: 首頁>>代碼示例>>Java>>正文


Java MemcacheService.delete方法代碼示例

本文整理匯總了Java中com.google.appengine.api.memcache.MemcacheService.delete方法的典型用法代碼示例。如果您正苦於以下問題:Java MemcacheService.delete方法的具體用法?Java MemcacheService.delete怎麽用?Java MemcacheService.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.appengine.api.memcache.MemcacheService的用法示例。


在下文中一共展示了MemcacheService.delete方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doGet

import com.google.appengine.api.memcache.MemcacheService; //導入方法依賴的package包/類
public void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws IOException {
	final PersistenceManager pm = PMF.get().getPersistenceManager();

	final Query query = pm.newQuery(RequestHash.class);
	try {
		List<RequestHash> results = (List<RequestHash>) query.execute();
		for (RequestHash requestHash : results) {
			final Md5Calculator md5Calculator = new Md5Calculator(
					requestHash.getRequestUri());
			final String newMd5 = md5Calculator.calculateMd5();
			if (newMd5 != null && !newMd5.equals(requestHash.getMd5())) {
				requestHash.setMd5(newMd5);
				requestHash.setDate(new Date());
				pm.makePersistent(requestHash);

				final MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
				syncCache.delete(requestHash.getRequestUri());
			}
		}
	} finally {
		query.closeAll();
		pm.close();
	}
}
 
開發者ID:devoxx,項目名稱:mobile-client,代碼行數:26,代碼來源:RecalculateMD5KeysServlet.java

示例2: star

import com.google.appengine.api.memcache.MemcacheService; //導入方法依賴的package包/類
public static Session star(Session session, boolean clearCache) {
	if (clearCache) {
		final String email = DataStore.getUserEmail();
		if (email != null) {
			final MemcacheService syncCache = MemcacheServiceFactory
					.getMemcacheService();
			syncCache.delete(email);
		}
	}

	final String sessionId = session.getSessionId();
	Session sessionDb = db.find(sessionId);
	if (sessionDb == null) {
		session.setEmailAddress(DataStore.getUserEmail());
		session = db.update(session);
	}
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();
	C2DMMessage.enqueueStarSessionMessage(RequestFactoryServlet
			.getThreadLocalRequest().getSession().getServletContext(),
			user.getEmail(), sessionId);
	return session;
}
 
開發者ID:devoxx,項目名稱:mobile-client,代碼行數:24,代碼來源:DevoxxService.java

示例3: unstar

import com.google.appengine.api.memcache.MemcacheService; //導入方法依賴的package包/類
public static void unstar(Session session, boolean clearCache) {
	if (clearCache) {
		final String email = DataStore.getUserEmail();
		if (email != null) {
			final MemcacheService syncCache = MemcacheServiceFactory
					.getMemcacheService();
			syncCache.delete(email);
		}
	}

	final String sessionId = session.getSessionId();
	Session sessionDb = db.find(sessionId);
	if (sessionDb != null) {
		db.delete(sessionDb.getId());
		UserService userService = UserServiceFactory.getUserService();
		User user = userService.getCurrentUser();
		C2DMMessage.enqueueUnstarSessionMessage(RequestFactoryServlet
				.getThreadLocalRequest().getSession().getServletContext(),
				user.getEmail(), session.getSessionId());
	}
}
 
開發者ID:devoxx,項目名稱:mobile-client,代碼行數:22,代碼來源:DevoxxService.java

示例4: doPost

import com.google.appengine.api.memcache.MemcacheService; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public final void doPost(final HttpServletRequest req,
                         final HttpServletResponse resp)
        throws IOException {
    // Validating unique subscription token before processing the message
    String subscriptionToken = System.getProperty(
            Constants.BASE_PACKAGE + ".subscriptionUniqueToken");
    if (!subscriptionToken.equals(req.getParameter("token"))) {
        resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        resp.getWriter().close();
        return;
    }

    ServletInputStream inputStream = req.getInputStream();

    // Parse the JSON message to the POJO model class
    JsonParser parser = JacksonFactory.getDefaultInstance()
            .createJsonParser(inputStream);
    parser.skipToKey("message");
    PubsubMessage message = parser.parseAndClose(PubsubMessage.class);

    // Store the message in the datastore
    Entity messageToStore = new Entity("PubsubMessage");
    messageToStore.setProperty("message",
            new String(message.decodeData(), "UTF-8"));
    messageToStore.setProperty("receipt-time", System.currentTimeMillis());
    DatastoreService datastore =
            DatastoreServiceFactory.getDatastoreService();
    datastore.put(messageToStore);

    // Invalidate the cache
    MemcacheService memcacheService =
            MemcacheServiceFactory.getMemcacheService();
    memcacheService.delete(Constants.MESSAGE_CACHE_KEY);

    // Acknowledge the message by returning a success code
    resp.setStatus(HttpServletResponse.SC_OK);
    resp.getWriter().close();
}
 
開發者ID:GoogleCloudPlatform,項目名稱:cloud-pubsub-samples-java,代碼行數:41,代碼來源:ReceiveMessageServlet.java

示例5: save

import com.google.appengine.api.memcache.MemcacheService; //導入方法依賴的package包/類
/**
 * Persists {@code this} test report to the given {@link com.google.appengine.api.datastore.DatastoreService}
 * and invalidate the cache.
 *
 * @param reports          the reports entry point
 */
public void save(Reports reports) {
    final Entity entity = new Entity(TEST_REPORT, buildTypeId + buildId);
    entity.setProperty("buildTypeId", buildTypeId);
    entity.setProperty("buildId", buildId);
    entity.setProperty("buildDate", buildDate);
    entity.setProperty("buildDuration", buildDuration);
    entity.setProperty("numberOfPassedTests", numberOfPassedTests);
    entity.setProperty("numberOfIgnoredTests", numberOfIgnoredTests);
    entity.setProperty("numberOfFailedTests", numberOfFailedTests);

    final JSONArray jsonArrayFailedTests = new JSONArray();
    for (Test oneFailingTest : failedTests) {
        jsonArrayFailedTests.put(oneFailingTest.asJson());
    }
    entity.setProperty("failedTests", new Text(jsonArrayFailedTests.toString()));

    final JSONArray jsonArrayIgnoredTests = new JSONArray();
    for (Test oneIgnoredTest : ignoredTests) {
        jsonArrayIgnoredTests.put(oneIgnoredTest.asJson());
    }
    entity.setProperty("ignoredTests", new Text(jsonArrayIgnoredTests.toString()));

    final DatastoreService datastoreService = reports.getDatastoreService();
    datastoreService.put(entity);

    final MemcacheService memcacheService = reports.getMemcacheService();
    memcacheService.delete(buildTypeId); // invalidate cache
}
 
開發者ID:GoogleCloudPlatform,項目名稱:appengine-tck,代碼行數:35,代碼來源:TestReport.java

示例6: release

import com.google.appengine.api.memcache.MemcacheService; //導入方法依賴的package包/類
public void release() {
    MemcacheService memcache = MemcacheServiceFactory.getMemcacheService(ns);
    memcache.delete(key);
}
 
開發者ID:feroult,項目名稱:yawp,代碼行數:5,代碼來源:Mutex.java


注:本文中的com.google.appengine.api.memcache.MemcacheService.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。