YouTip LogoYouTip

Memcached Prepend Data

# Memcached prepend Command The Memcached prepend command is used to prepend data to the **value** of an existing **key**. ### Syntax: The basic syntax format for the prepend command is as follows: prepend key flags exptime bytes value The parameters are explained as follows: * **key:** The key in the key-value structure, used to look up the cached value. * **flags:** An integer parameter that can include key-value pairs, used by the client to store additional information about the key-value pair. * **exptime:** The length of time (in seconds) to store the key-value pair in the cache (0 means forever). * **bytes:** The number of bytes to store in the cache. * **noreply (optional):** This parameter tells the server not to return a response. * **value:** The value to store (always on the second line) (can be understood as the value in the key-value structure). ### Example The example is as follows: * First, we store a key `` in Memcached with the value `memcached`. * Then, we use the `get` command to retrieve the value. * Then, we use the **prepend** command to prepend "redis" to the value of the key ``. * Finally, we use the `get` command again to retrieve the value. set 0 900 9 memcached STORED get VALUE 0 9 memcached END prepend 0 900 5 redis STORED get VALUE 0 14 redismemcached END ### Output If the data is added successfully, the output is: STORED Output message explanation: * **STORED:** Output after successful save. * **NOT_STORED:** The key does not exist on Memcached. * **CLIENT_ERROR:** Execution error.
← Php Connect MemcachedMemcached Install β†’