This topic describes the data types and parameters that Memcache Writer supports 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 following content describes similarity and difference between ApsaraDB for Memcache databases and user-created Memcached databases:
  • 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 based on the pay-as-you-go billing method.

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

Memcache Writer writes data only in text format. The method of converting data types varies based on the format of writing data.
  • text: Memcache Writer uses the specified column delimiter to serialize source data to a string.
  • binary: This format is not supported.

Parameters

Parameter Description Required Default value
datasource The connection name. It must be the same as the name of the added connection. You can add connections in the code editor. Yes N/A
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. This mode is not supported now.
  • replace: uses the source data to replace the data record with the same key in the destination ApsaraDB for Memcache database. This mode is not supported now.
  • 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. This mode is not supported now.
  • 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. This mode is not supported now.
Yes N/A
writeFormat The format in which Memcache Writer writes the source data. Only the text format is supported.

text: serializes 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.

Assume that the following source data exists:
| 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 N/A
expireTime The expiration time of the source data to be cached in ApsaraDB for Memcache. ApsaraDB for Memcache supports the following two types of expiration time:
  • unixtime: the UNIX timestamp, which indicates a specific time point in the future when the data expires. 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 period 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, which indicates that the data never expires.
batchSize The number of data records to write at a time. Set this parameter to a proper value based on your actual needs. This can greatly reduce the interactions between Data Integration and the ApsaraDB for Memcache database on 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 1,024

Configure Memcache Writer by using the codeless UI

The codeless user interface (UI) is not supported for Memcache Writer.

Configure Memcache Writer by using the code editor

The following example shows how to configure a sync node to write data to an ApsaraDB for Memcache database. For more information, see Create a sync node by using the code editor.
{
    "type":"job",
    "version":"2.0",// The version number.
    "steps":[
        { 
            "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"
            }
        ]
    }
}