> For the complete documentation index, see [llms.txt](https://jam2in.gitbook.io/arcus-memcached/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jam2in.gitbook.io/arcus-memcached/ascii-protocol/ch10-command-item-attribute.md).

# 10. Item Attribute 명령

Item attributes를 조회하는 getattr 명령과 변경하는 setattr 명령을 소개한다.

ARCUS에서 어떤 item attributes를 제공하는 지를 알고자 한다면, [Item Attibute 설명](/arcus-memcached/ascii-protocol/ch03-item-attributes.md)을 참고 바란다.

## getattr 명령

Item attributes를 조회하는 getattr 명령은 아래와 같다.

```
getattr <key> [<name> ...]\r\n
```

* \<key> - 대상 item의 key string
* \[\<name> ...] - 조회할 attribute name을 순차적으로 지정하는 것이며, 이를 생략하면, item 유형에 따라 조회가능한 모든 attributes 값을 조회한다.

성공 시의 response string은 아래와 같다. getattr 명령의 인자로 지정한 attribute name 순서대로 name과 value의 쌍을 리턴한다.

```
ATTR <name>=<value>\r\n
ATTR <name>=<value>\r\n
...
END\r\n
```

실패 시의 response string과 그 의미는 아래와 같다.

| Response String                         | 설명                                                           |
| --------------------------------------- | ------------------------------------------------------------ |
| "NOT\_FOUND"                            | key miss                                                     |
| "ATTR\_ERROR not found"                 | 인자로 지정한 attribute가 존재하지 않거나 해당 item 유형에서 지원되지 않는 attribute임. |
| "CLIENT\_ERROR bad command line format" | protocol syntax 틀림                                           |

## setattr 명령

Item attributes를 변경하는 setattr 명령은 아래와 같다. 모든 attributes에 대해 조회가 가능하지만, 변경은 일부 attributes에 대해서만 가능하다. 변경가능한 attributes로는 expiretime, maxcount, overflowaction, readable, maxbkeyrange가 있다.

```
setattr <key> <name>=<value> [<name>=<value> ...]\r\n
```

* \<key> - 대상 item의 key string
* \<name>=\<value> - 변경할 attribute의 name과 value 쌍을 하나 이상 명시하여야 한다.

이 명령의 response string과 그 의미는 아래와 같다.

| Response String                         | 설명                                                           |
| --------------------------------------- | ------------------------------------------------------------ |
| "OK"                                    | 성공                                                           |
| "NOT\_FOUND"                            | key miss                                                     |
| "ATTR\_ERROR not found"                 | 인자로 지정한 attribute가 존재하지 않거나 해당 item 유형에서 지원되지 않는 attribute임. |
| "ATTR\_ERROR bad value"                 | 해당 attribute에 대해 새로 변경하고자 하는 value가 allowed value가 아님.       |
| "CLIENT\_ERROR bad command line format" | protocol syntax 틀림                                           |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://jam2in.gitbook.io/arcus-memcached/ascii-protocol/ch10-command-item-attribute.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
