Memcache Services

Apcera provides the memcache service type and gateway, and semantic pipeline, for creating and consuming Memcached services.

Memcached is an open source cache designed to provide temporary storage for string data, typically to reduce multiple accesses to a database for the same data.

Creating Memcached services

The memcache service gateway does not require a provider. To implement a Memcached service, simply create the service and then bind one or more jobs to it.

Apcera provides semantic pipeline for the Memcached protocol against which you can write rules to inject logic into the connection.

To create a Memcache service, use the following syntax:

apc service create <service name> --type memcache

For example:

apc service create memcached --type memcache
╭────────────────────────────────────────────────────╮
│             Service Creation Settings              │
├───────────────┬────────────────────────────────────┤
│      Service: │ service::/sandbox/admin::memcached │
│ Service Type: │ memcache                           │
╰───────────────┴────────────────────────────────────╯

Is this correct? [Y/n]: 
Creating service... done
Success!

Note that the service is provider-less:

apc service list
Working in "/sandbox/admin"
╭────────────────────────────┬──────────┬────────────────┬────────────────────────────────────┬────────────────────────────────────────────────────────────────╮
│ Name                       │ Type     │ Namespace      │ Provider                           │ Description                                                    │
├────────────────────────────┼──────────┼────────────────┼────────────────────────────────────┼────────────────────────────────────────────────────────────────┤
│ memcached                  │ memcache │ /sandbox/admin │                                    │                                                                │
╰────────────────────────────┴──────────┴────────────────┴────────────────────────────────────┴────────────────────────────────────────────────────────────────╯

Instead, an instance of the Memcached server is created and run as a job in the system:

apc job list
Working in "/sandbox/admin"
╭───────────────────────┬──────┬────────────────┬─────────┬───────────╮
│ Name                  │ Type │ Namespace      │ Status  │ Instances │
├───────────────────────┼──────┼────────────────┼─────────┼───────────┤
│ memcache/memcached    │ job  │ /sandbox/admin │ started │ 1/1       │
╰───────────────────────┴──────┴────────────────┴─────────┴───────────╯

Creating Memcached bindings

To bind a job to the service:

apc service bind memcached --job web-app
╭───────────────────────╮
│ Service Bind Settings │
├───────────┬───────────┤
│ App Name: │ web-app   │
│  Service: │ memcached │
╰───────────┴───────────╯

Is this correct? [Y/n]: 
Binding service "memcached" to "web-app"...
Job must be stopped to bind to service. Do you want to stop it, apply the binding, and start it again?
Restart and proceed? [Y/n]: 
Stopping job... done
Creating binding... done
Starting job... done
Waiting for the job to start...
╭────────────────────────────────────────╮
│     Binding Environment Variables      │
├────────────────────────────────────────┤
│ "E423FB195B0D4E4A88ADE864DBBFAB56_URI" │
│ "MEMCACHED_URI"                        │
│ "MEMCACHE_URI"                         │
╰────────────────────────────────────────╯
Success!

The resulting URI points to the semantic pipeline associated with the Memcache protocol, but to the job, the connection appears to be directly to the Memcached server.