This topic describes the parameters that are supported by Memcache Writer and how to configure Memcache Writer by using the codeless user interface (UI) and code editor.

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

ApsaraDB for Memcache is available right 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 the similarities and differences between ApsaraDB for Memcache databases and self-managed Memcached databases:
  • ApsaraDB for Memcache databases are compatible with the Memcached protocol like self-managed Memcached databases. 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. The pay-as-you-go billing method is used for these services.

Memcache Writer writes data to ApsaraDB for Memcache databases in compliance with the Memcached protocol.

Memcache Writer writes data only in the text format. The method of converting data types varies based on the format in which Memcache Writer writes 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 name of the data source. It must be the same as the name of the added data source. You can add data sources by using the code editor. Yes No default value
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.
  • replace: uses the source data to replace the data record that has the same key as the source data in the destination ApsaraDB for Memcache database. This mode is not supported.
  • append: adds the source data to the end of an existing data record that has the same key as the source data, but does not update the expiration time of the existing data record. This mode is not supported.
  • prepend: adds the source data to the beginning of an existing data record that has the same key as the source data, but does not update the expiration time of the existing data record. This mode is not supported.
Yes No default value
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 strings by using the specified delimiter. Then, Memcache Writer writes key-value pairs to ApsaraDB for Memcache databases.

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 databases in the following format:
| KEY (OCS) | VALUE(OCS) |
| --------- |:---------- |
| 23        | CDP\^100   |
No No default value
expireTime The expiration time of the source data that is cached in ApsaraDB for Memcache databases. ApsaraDB for Memcache supports the expiration time in the following formats:
  • unixtime: the UNIX timestamp, which indicates a specific point in time 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 period of time in seconds starting from the current point in time. It specifies the period during which data is valid.
Note If the specified expiration time is greater than 30 days, the server identifies the time as a 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 an appropriate value based on your business requirements. This greatly reduces the interactions between Data Integration and ApsaraDB for Memcache and increases throughput. If you set this parameter to an excessively large value, an out of memory (OOM) error may occur during data synchronization. No 1,024

Configure Memcache Writer by using the codeless UI

This method is not supported.

Configure Memcache Writer by using the code editor

In the following code, a synchronization node is configured to write data to an ApsaraDB for Memcache database by using the code editor. 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 that is cached in ApsaraDB for Memcache databases. 
                "indexes":0,
                "datasource":"",// The name of the data source. 
                "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":true,// Specifies whether to enable bandwidth throttling. The value false indicates that bandwidth throttling is disabled, and the value true indicates that bandwidth throttling is enabled. The mbps parameter takes effect only when the throttle parameter is set to true. 
            "concurrent":1, // The maximum number of parallel threads. 
            "mbps":"12"// The maximum transmission rate.
        }
    },
    "order":{
        "hops":[
            {
                "from":"Reader",
                "to":"Writer"
            }
        ]
    }
}