edit-icon download-icon

Configure Memcache writer

Last Updated: Mar 21, 2018

ApsaraDB for Memcache (formerly known as ApsaraDB for Memcache) is a seamlessly scalable distributed memory database service with high performance and reliability. Based on the Apsara distributed system and high‑performance storage, ApsaraDB for Memcache provides a complete set of solutions for master/slave hot backup, disaster recovery, business monitoring, data migration, and other scenarios.

ApsaraDB for Memcache supports the out‑of‑the‑box deployment mode, and relieves the database load for dynamic web applications by using the cache service, thus accelerating the overall response of the website.

Similar to the local Memcache databases, ApsaraDB for Memcache is compatible with the Memcached protocol. You can use it directly in your operating environment. The difference is that the hardware and data of ApsaraDB for Memcache are deployed in the cloud, which provides complete infrastructure, network security, and system maintenance services. All these services are billed on a Pay-As-You-Go basis.

Memcache Writer writes data into Memcache channels based on the Memcached protocol.

Currently, Memcache Writer supports only one write mode. Data types written in different modes are converted differently.

  • text: Memcache Writer serializes source data to the String type, and uses your fieldDelimiter as the delimiter.

  • binary: Currently not supported.

Parameter description

  • datasource

    • Description: Data source name. It must be identical to the data source name added. Adding data source is supported in script mode.

    • Required: Yes

    • Default value: None
  • writeMode

    • Description: Memcache Writer writes data in the following modes.

      • set: Store the data.
      • add: Store the data only when this key does not exist (not supported currently).
      • replace: Store the data only when this key exists (not supported currently).
      • append: Store data after the existing key, and ignore exptime (not supported currently).
      • prepend: Store data before the existing key, and ignore exptime (not supported currently).
    • Required: Yes

    • Default value: None

  • writeFormat

    • Description: Currently, Memcache Writer supports writing data in only one format.

      TEXT: Serialize the source data to the text format with the first field being the key written into Memcache, and all subsequent fields to the String type. Use fieldDelimiter that you specified as the delimiter to concatenate the text data into a complete string and write it into Memcache.

      1. For example, the source data is:
      2. | ID | NAME | COUNT |
      3. | --------- |:-------|:-----|
      4. | 23 | "CDP"| 100 |

      If fieldDelimiter is specified as \^, the data format written into Memcache is.

      1. | KEY (ApsaraDB for Memcache) | VALUE(ApsaraDB for Memcache) |
      2. | --------- |:-------|
      3. | 23 | CDP\^100 |
    • Required: No

    • Default value: None
  • expireTime

    • Description: The cache invalidation time for the Memcache value. Currently, Memcache supports two types of the invalidation time.

      • Unix time (number of seconds since January 1, 1970) indicates that data is invalid at a certain time point in the future.
      • The relative time (in seconds) starting from the current time point, which indicates the time length from the current time before data is invalid.

        Note:

        If the invalidation time is larger than 60*60*24*30 (30 days), the server identifies the invalidation time as the Unix time.

    • Required: No

    • Default value: 0,0 (valid permanently)

  • batchSize

    • Description: The quantity of records submitted in one operation. Setting this parameter can greatly reduce the interactions between CDP and Memcache over the network, and increase the overall throughput. However, an excessively large value may cause the running process of CDP to become out of memory. (Writing in batches is not supported for the current Memcache version.)

    • Required: No

    • Default value: 1024

Development in wizard mode

Currently, development in wizard mode is not supported.

Development in script mode

Use the data generated from memory and imported into Memcache.

  1. {
  2. "type": "job",
  3. "version": "1.0",
  4. "configuration": {
  5. "setting": {
  6. "key": "value"
  7. },
  8. "reader": {
  9. },
  10. "writer": {
  11. "plugin": "odps",
  12. "parameter": {
  13. "datasource": "datasourceName",
  14. "writeMode": "set|add|replace|append|prepend",
  15. "writeFormat": "text|binary",
  16. "fieldDelimiter": "if the writeFormat is text",
  17. "expireTime": 1000,
  18. "batchSize": 1000
  19. }
  20. }
  21. }
  22. }
Thank you! We've received your feedback.