mirror of
https://github.com/google/nomulus.git
synced 2025-07-24 19:48:32 +02:00
Remove all vestiges of memcache
Memcache is already off but now it's not in the code anymore. This includes removing domain creation failfast, since that is actually slower now than just running the flow - all you gain is a non-transactional read over a transactional read, but the cost is that you always pay that read, which is going to drive up latency. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=158183506
This commit is contained in:
parent
445faab977
commit
ae039aa0d8
37 changed files with 29 additions and 341 deletions
|
@ -21,7 +21,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||
import static org.json.XML.toJSONObject;
|
||||
|
||||
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
|
||||
import com.google.appengine.tools.development.testing.LocalMemcacheServiceTestConfig;
|
||||
import com.google.appengine.tools.development.testing.LocalModulesServiceTestConfig;
|
||||
import com.google.appengine.tools.development.testing.LocalServiceTestConfig;
|
||||
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
|
||||
|
@ -96,7 +95,6 @@ public final class AppEngineRule extends ExternalResource {
|
|||
|
||||
private boolean withDatastore;
|
||||
private boolean withLocalModules;
|
||||
private boolean withMemcache;
|
||||
private boolean withTaskQueue;
|
||||
private boolean withUserService;
|
||||
private boolean withUrlFetch;
|
||||
|
@ -122,12 +120,6 @@ public final class AppEngineRule extends ExternalResource {
|
|||
return this;
|
||||
}
|
||||
|
||||
/** Turn on the use of local modules. */
|
||||
public Builder withMemcache() {
|
||||
rule.withMemcache = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/** Turn on the task queue service. */
|
||||
public Builder withTaskQueue() {
|
||||
|
@ -281,9 +273,6 @@ public final class AppEngineRule extends ExternalResource {
|
|||
.addBasicScalingModuleVersion("tools", "1", 1)
|
||||
.addBasicScalingModuleVersion("backend", "1", 1));
|
||||
}
|
||||
if (withMemcache) {
|
||||
configs.add(new LocalMemcacheServiceTestConfig());
|
||||
}
|
||||
if (withTaskQueue) {
|
||||
File queueFile = temporaryFolder.newFile("queue.xml");
|
||||
Files.asCharSink(queueFile, UTF_8).write(taskQueueXml);
|
||||
|
|
|
@ -829,9 +829,9 @@ public class DatastoreHelper {
|
|||
saveResource(resource, wantBackup);
|
||||
}});
|
||||
// Force the session cache to be cleared so that when we read the resource back, we read from
|
||||
// Datastore (or memcache) and not from the session cache. This is needed to trigger Objectify's
|
||||
// load process (unmarshalling entity protos to POJOs, nulling out empty collections, calling
|
||||
// @OnLoad methods, etc.) which is bypassed for entities loaded from the session cache.
|
||||
// Datastore and not from the session cache. This is needed to trigger Objectify's load process
|
||||
// (unmarshalling entity protos to POJOs, nulling out empty collections, calling @OnLoad
|
||||
// methods, etc.) which is bypassed for entities loaded from the session cache.
|
||||
ofy().clearSessionCache();
|
||||
return ofy().load().entity(resource).now();
|
||||
}
|
||||
|
@ -872,7 +872,7 @@ public class DatastoreHelper {
|
|||
}});
|
||||
}
|
||||
// Force the session to be cleared so that when we read it back, we read from Datastore
|
||||
// and not from the transaction cache or memcache.
|
||||
// and not from the transaction's session cache.
|
||||
ofy().clearSessionCache();
|
||||
for (R resource : resources) {
|
||||
ofy().load().entity(resource).now();
|
||||
|
@ -984,7 +984,7 @@ public class DatastoreHelper {
|
|||
ofy().saveWithoutBackup().entities(resources);
|
||||
}});
|
||||
// Force the session to be cleared so that when we read it back, we read from Datastore
|
||||
// and not from the transaction cache or memcache.
|
||||
// and not from the transaction's session cache.
|
||||
ofy().clearSessionCache();
|
||||
return ImmutableList.copyOf(ofy().load().entities(resources).values());
|
||||
}
|
||||
|
@ -992,7 +992,7 @@ public class DatastoreHelper {
|
|||
public static void deleteResource(final Object resource) {
|
||||
ofy().deleteWithoutBackup().entity(resource).now();
|
||||
// Force the session to be cleared so that when we read it back, we read from Datastore and
|
||||
// not from the transaction cache or memcache.
|
||||
// not from the transaction's session cache.
|
||||
ofy().clearSessionCache();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.testing;
|
||||
|
||||
import static com.google.appengine.tools.development.testing.LocalMemcacheServiceTestConfig.getLocalMemcacheService;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
import com.google.appengine.api.memcache.MemcacheServicePb.MemcacheFlushRequest;
|
||||
import com.google.appengine.tools.development.LocalRpcService;
|
||||
import com.googlecode.objectify.Key;
|
||||
|
||||
/** Utilities for manipulating memcache in tests. */
|
||||
public class MemcacheHelper {
|
||||
|
||||
/** Clear out memcache */
|
||||
public static void clearMemcache() {
|
||||
getLocalMemcacheService().flushAll(
|
||||
new LocalRpcService.Status(), MemcacheFlushRequest.newBuilder().build());
|
||||
}
|
||||
|
||||
/** Clears memcache, inserts the specific keys requested, and clears the session cache. */
|
||||
public static void setMemcacheContents(Key<?>... keys) {
|
||||
// Clear out the session cache. This is needed so that the calls to loadWithMemcache() below
|
||||
// actually go to datastore and write to memcache instead of bottoming out at the session cache.
|
||||
ofy().clearSessionCache();
|
||||
clearMemcache();
|
||||
// Load the entities we want to be in memcache. If an entity's type is not marked with @Cache it
|
||||
// will be ignored.
|
||||
ofy().loadWithMemcache().keys(keys).values();
|
||||
// Clear out the session cache again, since it now contains the newly loaded types.
|
||||
ofy().clearSessionCache();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue