Skip to content
Open
Show file tree
Hide file tree
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
79 changes: 36 additions & 43 deletions src/main/java/net/spy/memcached/ArcusClient.java

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions src/main/java/net/spy/memcached/OperationFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import javax.security.sasl.SaslClient;

import net.spy.memcached.collection.Attributes;
import net.spy.memcached.collection.BTreeFindPosition;
import net.spy.memcached.collection.BTreeFindPositionWithGet;
import net.spy.memcached.collection.BTreeGetBulk;
Expand All @@ -39,6 +38,7 @@
import net.spy.memcached.collection.CollectionPipedInsert;
import net.spy.memcached.collection.CollectionPipedUpdate;
import net.spy.memcached.collection.CollectionUpdate;
import net.spy.memcached.collection.SetAttributes;
import net.spy.memcached.collection.SetPipedExist;
import net.spy.memcached.ops.BTreeFindPositionOperation;
import net.spy.memcached.ops.BTreeFindPositionWithGetOperation;
Expand Down Expand Up @@ -156,35 +156,35 @@ public interface OperationFactory {
* Get the key and resets its timeout.
*
* @param key the key to get a value for and reset its timeout
* @param expiration the new expiration for the key
* @param exp the new expiration for the key
* @param cb the callback that will contain the result
* @return a new GetAndTouchOperation
*/
GetOperation getAndTouch(String key, int expiration, GetOperation.Callback cb);
GetOperation getAndTouch(String key, long exp, GetOperation.Callback cb);

/**
* Gets (with CAS support) the key and resets its timeout.
*
* @param key the key to get a value for and reset its timeout
* @param expiration the new expiration for the key
* @param exp the new expiration for the key
* @param cb the callback that will contain the result
* @return a new GetsAndTouchOperation
*/
GetsOperation getsAndTouch(String key, int expiration, GetsOperation.Callback cb);
GetsOperation getsAndTouch(String key, long exp, GetsOperation.Callback cb);

/**
* Create a mutator operation.
*
* @param m the mutator type
* @param key the mutatee key
* @param key the mutate key
* @param by the amount to increment or decrement
* @param def the default value
* @param exp expiration in case we need to default (0 if no default)
* @param cb the status callback
* @return the new mutator operation
*/
MutatorOperation mutate(Mutator m, String key, int by,
long def, int exp, OperationCallback cb);
long def, long exp, OperationCallback cb);

/**
* Get a new StatsOperation.
Expand All @@ -206,18 +206,18 @@ MutatorOperation mutate(Mutator m, String key, int by,
* @param cb the status callback
* @return the new store operation
*/
StoreOperation store(StoreType storeType, String key, int flags, int exp,
StoreOperation store(StoreType storeType, String key, int flags, long exp,
byte[] data, OperationCallback cb);

/**
* Create a touch operation.
*
* @param key the key to touch
* @param expiration the new expiration time
* @param exp the new expiration time

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javadoc 정렬이 ν•„μš”ν•©λ‹ˆλ‹€. λ³€κ²½ 사항듀에 λŒ€ν•΄μ„œλ§Œ ν™•μΈν•΄μ£Όμ„Έμš”

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 λ°˜μ˜ν•΄μ•Ό ν•©λ‹ˆλ‹€.

* @param cb the status callback
* @return the new touch operation
*/
TouchOperation touch(String key, int expiration, OperationCallback cb);
TouchOperation touch(String key, long exp, OperationCallback cb);

/**
* Get a concatenation operation.
Expand All @@ -244,7 +244,7 @@ ConcatenationOperation cat(ConcatenationType catType, long casId,
* @return the new store operation
*/
CASOperation cas(StoreType t, String key, long casId, int flags,
int exp, byte[] data, OperationCallback cb);
long exp, byte[] data, OperationCallback cb);

/**
* Create a new version operation.
Expand Down Expand Up @@ -274,8 +274,7 @@ CASOperation cas(StoreType t, String key, long casId, int flags,
* @param cb the status callback
* @return a new SetAttrOperation
*/
SetAttrOperation setAttr(String key, Attributes attrs,
OperationCallback cb);
SetAttrOperation setAttr(String key, SetAttributes attrs, OperationCallback cb);

/**
* Get item attributes
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/spy/memcached/collection/Attributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import net.spy.memcached.compat.SpyObject;

public class Attributes extends SpyObject {
public class Attributes extends SpyObject implements SetAttributes {
public static final Integer DEFAULT_FLAGS = 0;
public static final Integer DEFAULT_EXPIRETIME = 0;

Expand All @@ -35,7 +35,8 @@ public Attributes(Integer expireTime) {
this.expireTime = expireTime;
}

protected String stringify() {
@Override
public String stringify() {
if (str != null) {
return str;
}
Expand Down Expand Up @@ -64,6 +65,7 @@ public String toString() {
return (str == null) ? stringify() : str;
}

@Override
public int getLength() {
return (str == null) ? stringify().length() : str.length();
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/net/spy/memcached/collection/BTreeCreate.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ public class BTreeCreate extends CollectionCreate {

private static final String COMMAND = "bop create";

public BTreeCreate(int flags, Integer expTime, Long maxCount,
CollectionOverflowAction overflowAction, Boolean readable, boolean noreply) {
super(CollectionType.btree, flags, expTime, maxCount, overflowAction, readable, noreply);
public BTreeCreate(int flags, CreateAttributes option, boolean noreply) {
super(CollectionType.btree, flags, option, noreply);
}

public String getCommand() {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/spy/memcached/collection/BTreeInsert.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public class BTreeInsert<T> extends CollectionInsert<T> {

private static final String COMMAND = "bop insert";

public BTreeInsert(T value, byte[] eFlag, RequestMode requestMode, CollectionAttributes attr) {
super(CollectionType.btree, value, eFlag, requestMode, attr);
public BTreeInsert(T value, byte[] eFlag, RequestMode requestMode,
CreateAttributes createAttributes) {
super(CollectionType.btree, value, eFlag, requestMode, createAttributes);
}

public String getCommand() {
Expand Down
29 changes: 15 additions & 14 deletions src/main/java/net/spy/memcached/collection/BTreeInsertAndGet.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,28 @@ public class BTreeInsertAndGet<T> extends CollectionGet {
private BKeyObject bKey;

public BTreeInsertAndGet(long bkey, byte[] eFlag, T value, boolean updateIfExist,
CollectionAttributes attributesForCreate) {
if (updateIfExist) {
this.collection = new BTreeUpsert<>(value, eFlag, RequestMode.GET_TRIM, attributesForCreate);
} else {
this.collection = new BTreeInsert<>(value, eFlag, RequestMode.GET_TRIM, attributesForCreate);
}
this.updateIfExist = updateIfExist;
this.bKey = new BKeyObject(bkey);
this.eHeadCount = 2;
this.eFlagIndex = 1;
CreateAttributes createAttributes) {
this(new BKeyObject(bkey), eFlag, value, updateIfExist, createAttributes);
}

public BTreeInsertAndGet(byte[] bkey, byte[] eFlag, T value, boolean updateIfExist,
CollectionAttributes attributesForCreate) {
CreateAttributes createAttributes) {
this(new BKeyObject(bkey), eFlag, value, updateIfExist, createAttributes);
}

private BTreeInsertAndGet(BKeyObject bKey, byte[] eFlag, T value, boolean updateIfExist,
CreateAttributes createOptionForCreate) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ „μ²΄μ μœΌλ‘œ CreateAttributes의 λ³€μˆ˜λͺ…을 createAttributes둜 톡일 κ°€λŠ₯ν•œκ°€μš”?

@oliviarla oliviarla Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

λ‹€μ‹œ μƒκ°ν•΄λ³΄λ‹ˆ attributes둜 ν†΅μΌν•˜λŠ” 게 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€. (CollectionAttributes와 좩돌 μ‹œμ—λŠ” createAttributes μ‚¬μš©)

if (updateIfExist) {
this.collection = new BTreeUpsert<>(value, eFlag, RequestMode.GET_TRIM, attributesForCreate);
this.collection = new BTreeUpsert<>(
value, eFlag, RequestMode.GET_TRIM, createOptionForCreate
);
} else {
this.collection = new BTreeInsert<>(value, eFlag, RequestMode.GET_TRIM, attributesForCreate);
this.collection = new BTreeInsert<>(
value, eFlag, RequestMode.GET_TRIM, createOptionForCreate
);
}
this.updateIfExist = updateIfExist;
this.bKey = new BKeyObject(bkey);
this.bKey = bKey;
this.eHeadCount = 2;
this.eFlagIndex = 1;
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/spy/memcached/collection/BTreeUpsert.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ public class BTreeUpsert<T> extends CollectionInsert<T> {

private static final String COMMAND = "bop upsert";

public BTreeUpsert(T value, byte[] eFlag, RequestMode requestMode, CollectionAttributes attr) {
super(CollectionType.btree, value, eFlag, requestMode, attr);
public BTreeUpsert(T value, byte[] eFlag, RequestMode requestMode,
CreateAttributes createAttributes) {
super(CollectionType.btree, value, eFlag, requestMode, createAttributes);
}

public String getCommand() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public CollectionAttributes(Integer expireTime,
this.overflowAction = overflowAction;
}

protected String stringify() {
@Override
public String stringify() {
StringBuilder b = new StringBuilder();

if (flags != null) {
Expand Down Expand Up @@ -81,14 +82,11 @@ protected String stringify() {
}

@Override
public String toString() {
return (stringCache == null) ? stringify() : stringCache;
}

public int getLength() {
return (stringCache == null) ? stringify().length() : stringCache.length();
}

@Override
public void setAttribute(String attribute) {
String[] splited = attribute.split("=");
assert splited.length == 2 : "An attribute should be given in \"name=value\" format.";
Expand All @@ -97,13 +95,7 @@ public void setAttribute(String attribute) {
String value = splited[1];

try {
if ("flags".equals(name)) {
flags = Integer.parseInt(value);
} else if ("expiretime".equals(name)) {
expireTime = Integer.parseInt(value);
} else if ("type".equals(name)) {
type = CollectionType.find(value);
} else if ("count".equals(name)) {
if ("count".equals(name)) {
count = Long.parseLong(value);
} else if ("maxcount".equals(name)) {
maxCount = Long.parseLong(value);
Expand Down Expand Up @@ -138,6 +130,9 @@ public void setAttribute(String attribute) {
}
} else if ("trimmed".equals(name)) {
trimmed = Long.parseLong(value);
} else {
// flags, expiretime, type are handled by the base class.
super.setAttribute(attribute);
}
} catch (Exception e) {
getLogger().info(e, e);
Expand Down
Loading
Loading