Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class MemcachedClientWrapper {

/**
* Used to represent an object retrieved from Memcached along with its CAS information
*
*
* @author Weisz, Gustavo E.
*/
private class ObjectWithCas {
Expand Down Expand Up @@ -95,7 +95,7 @@ public MemcachedClientWrapper() {

/**
* Converts the MyBatis object key in the proper string representation.
*
*
* @param key
* the MyBatis object key.
* @return the proper string representation.
Expand Down Expand Up @@ -195,7 +195,7 @@ private Object retrieve(final String keyString) {

/**
* Retrieves an object along with its cas using the given key
*
*
* @param keyString
* @return
* @throws Exception
Expand Down Expand Up @@ -292,9 +292,9 @@ private void storeInMemcached(String keyString, Object value) {

/**
* Tries to update an object value in memcached considering the cas validation
*
*
* Returns true if the object passed the cas validation and was modified.
*
*
* @param keyString
* @param value
* @return
Expand All @@ -319,9 +319,9 @@ private boolean storeInMemcached(String keyString, ObjectWithCas value) {

/**
* Tries to store an object identified by a key in Memcached.
*
*
* Will fail if the object already exists.
*
*
* @param keyString
* @param value
* @return
Expand Down Expand Up @@ -370,31 +370,40 @@ public Object removeObject(Object key) {
public void removeGroup(String id) {
String groupKey = toKeyString(id);

ObjectWithCas group = getGroup(groupKey);
Set<String> groupValues;
// remove namespace key into memcached
// Optimistic lock approach...
boolean jobDone = false;

while (!jobDone) {
ObjectWithCas group = getGroup(groupKey);
Set<String> groupValues;

if (group == null || group.getObject() == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("No need to flush cached entries for group '" + id + "' because is empty");
}
return;
}

if (group == null || group.getObject() == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("No need to flush cached entries for group '" + id + "' because is empty");
LOG.debug("Flushing keys: " + group);
}
return;
}

if (LOG.isDebugEnabled()) {
LOG.debug("Flushing keys: " + group);
}
groupValues = (Set<String>) group.getObject();

groupValues = (Set<String>) group.getObject();
for (String key : groupValues) {
client.delete(key);
}

for (String key : groupValues) {
client.delete(key);
}
if (LOG.isDebugEnabled()) {
LOG.debug("Flushing group: " + groupKey);
}

if (LOG.isDebugEnabled()) {
LOG.debug("Flushing group: " + groupKey);
}
groupValues = (Set<String>) group.getObject();
groupValues.clear();

client.delete(groupKey);
jobDone = storeInMemcached(groupKey, group);
}
}

@Override
Expand Down