The following project demonstrates the interaction between MC-Server and MC-Client. The gb.memcached component, which represents an MC client, is used for the MC client.
If no MC server exists in the system, an error message is displayed immediately after the programme is started and the programme is terminated.
Once the programme has been started, create a new MC client and connect it to the (started) MC server on port 11211. You can then save a text to the server in the memory. You then have the 60 seconds defined in the programme to read the value from the memory again. After this time, any further attempt to read the content will be acknowledged with an error message. You can reduce the storage time from 60 seconds to 5 seconds as a test. If you have saved a value, you can also manually remove the saved text from the memory by deleting the corresponding key-value pair. You can also delete the memory completely for all saved values in the example programme.
Figure 22.10.2.1: Memchached client (GUI)
As a speciality, you can store a positive integer (z ≥ 0) - here under the key 'number' - in the memory and change the value there by decrementing or incrementing with a specified integer value. Please note that when decrementing, the smallest stored value is zero, even if you decrement the value several times afterwards. This special feature is always useful if you need to manage certain counters at lightning speed, for example.