This topic describes the data types and parameters supported by Memcache Writer and how to configure it by using the code editor.

ApsaraDB for Memcache is a distributed in-memory database service with high performance, reliability, and scalability. Based on the Apsara distributed operating system and high-performance storage technologies, ApsaraDB for Memcache provides a complete database solution with hot standby, fault recovery, business monitoring, and data migration features.

ApsaraDB for Memcache is immediately available after an instance is created. It relieves the load on databases from dynamic websites and applications by caching data in the memory and therefore improves the response speed of websites and applications.

The similarity and difference between ApsaraDB for Memcache databases and user-created Memcached databases are as follows:

  • Same as user-created Memcached databases, ApsaraDB for Memcache databases are compatible with the Memcached protocol. ApsaraDB for Memcache databases can be directly used in your environments.
  • The difference is that the data, hardware infrastructure, network security, and system maintenance services used by ApsaraDB for Memcache databases are all deployed on the cloud. These services are billed in pay-as-you-go mode.

Memcache Writer writes data to ApsaraDB for Memcache databases based on the Memcached protocol.

Currently, Memcache Writer writes data only in text format. The method of converting data types varies with the format of writing data.

  • text: Memcache Writer uses the specified column delimiter to serialize source data to a string.
  • binary: Currently, this format is not supported.

Parameters

Parameter Description Required Default value
datasource The connection name. It must be identical to the name of the added connection. You can add connections in the code editor. Yes None
writeMode The write mode. Valid values:
  • set: stores the source data.
  • add: stores the source data only when its key does not exist in the destination ApsaraDB for Memcache database. Currently, this mode is not supported.
  • replace: uses the source data to replace the data record with the same key in the destination ApsaraDB for Memcache database. Currently, this mode is not supported.
  • append: adds the value of the source data to the end of the value of an existing data record with the same key in the destination ApsaraDB for Memcache database, but does not update the expiration time of the existing data record. Currently, this mode is not supported.
  • prepend: adds the value of the source data to the beginning of the value of an existing data record with the same key in the destination ApsaraDB for Memcache database, but does not update the expiration time of the existing data record. Currently, this mode is not supported.
Yes None
writeFormat The format in which Memcache Writer writes the source data. Currently, only the text format is supported.

text: serialize the source data to the text format. Memcache Writer uses the first column of the source data as the key and serializes the subsequent columns to the value by using the specified delimiter. Then, Memcache Writer writes the key-value pair to ApsaraDB for Memcache.

For example, the source data is as follows:
| ID   | NAME  | COUNT|
| ---- |:------|:-----|
| 23   | "CDP" | 100  |
If you set the column delimiter to a backslash and a caret (\^), data is written to ApsaraDB for Memcache in the following format:
| KEY (OCS) | VALUE(OCS) |
| --------- |:---------- |
| 23        | CDP\^100   |
No None
expireTime The expiration time of the source data to be cached in ApsaraDB for Memcache. Currently, ApsaraDB for Memcache supports the following two types of expiration time:
  • unixtime: the UNIX timestamp, indicating that data is invalid at a certain time point in the future. The UNIX timestamp represents the number of seconds that have elapsed since 00:00:00 on January 1, 1970.
  • seconds: the relative time in seconds starting from the current time point. It specifies the time range during which data is valid.
Note If the specified expiration time is larger than 30 days, the server identifies the time as the UNIX timestamp.
No 0, indicating that the data never expires
batchSize The number of data records to write at a time. Setting this parameter can greatly reduce the interactions between Data Integration and the ApsaraDB for Memcache database over the network, and increase the throughput. However, an excessively large value may lead to the out of memory (OOM) error during the data synchronization process. No 1024

Configure Memcache Writer by using the codeless UI

Currently, the codeless user interface (UI) is not supported for Memcache Writer.

Configure Memcache Writer by using the code editor

In the following code, a node is configured to write data to an ApsaraDB for Memcache database.

{
    "type":"job",
    "version":"2.0",// The version number.
    "steps":[
        {// The following template is used to configure Stream Reader. For more information, see the corresponding topic.
            "stepType":"stream",
            "parameter":{},
            "name":"Reader",
            "category":"reader"
        },
        {
            "stepType":"ocs",// The writer type.
            "parameter":{
                "writeFormat":"text",// The format in which Memcache Writer writes the source data.
                "expireTime":1000,// The expiration time of the source data to be cached in ApsaraDB for Memcache.
                "indexes":0,
                "datasource":"",// The connection name.
                "writeMode":"set",// The write mode.
                "batchSize":"256"// The number of data records to write at a time.
            },
            "name":"Writer",
            "category":"writer"
        }
    ],
    "setting":{
        "errorLimit":{
            "record":"0"// The maximum number of dirty data records allowed.
        },
        "speed":{
            "throttle":false,// Specifies whether to enable bandwidth throttling. A value of false indicates that the bandwidth is not throttled. A value of true indicates that the bandwidth is throttled. The maximum transmission rate takes effect only if you set this parameter to true.
            "concurrent":1,// The maximum number of concurrent threads.
        }
    },
    "order":{
        "hops":[
            {
                "from":"Reader",
                "to":"Writer"
            }
        ]
    }
}