Go to main content

man pages section 8: System Administration Commands

Exit Print View

Updated: Wednesday, July 27, 2022

memcached (8)


memcached - performance memory object caching system


memcached [options]


MEMCACHED(8)                System Manager's Manual               MEMCACHED(8)

       memcached - high-performance memory object caching system

       memcached [options]

       This  manual page documents briefly the memcached memory object caching

       memcached is a flexible memory object caching daemon designed to  alle-
       viate  database  load in dynamic web applications by storing objects in
       memory.  It's based on libevent to scale to any  size  needed,  and  is
       specifically  optimized  to  avoid swapping and always use non-blocking

       These programs follow the usual GNU command line syntax. A  summary  of
       options is included below.

       -s, --unix-socket=<file>
              Unix socket path to listen on (disables network support).

       -A, --enable-shutdown
              Enable ascii "shutdown" command.

       -a, --unix-mask=<perms>
              Permissions  (in  octal  format) for Unix socket created with -s

       -l, --listen=<addr>
              Listen on <addr>; default to INADDR_ANY. <addr> may be specified
              as host:port.  If you don't specify a port number, the value you
              specified with -p or  -U  is  used.  You  may  specify  multiple
              addresses separated by comma or by using -l multiple times. This
              is an important option to consider as there is no other  way  to
              secure  the  installation.  Binding to an internal or firewalled
              network interface is suggested.

       -d, --daemon
              Run memcached as a daemon.

       -u, --user=<username>
              Assume the identity of <username> (only when run as root).

       -m, --memory-limit=<num>
              Use <num> MB memory max to use for object storage;  the  default
              is 64 megabytes.

       -c, --conn-limit=<num>
              Use <num> max simultaneous connections; the default is 1024.

       -R, --max-reqs-per-event=<num>
              This  option  seeks  to  prevent  client starvation by setting a
              limit to the number  of  sequential  requests  the  server  will
              process  from an individual client connection. Once a connection
              has exceeded this value, the server will attempt to process  I/O
              on  other  connections  before handling any further request from
              this connection. The default value for this option is 20.

       -k, --lock-memory
              Lock down all paged memory. This is a somewhat dangerous  option
              with  large caches, so consult the README and memcached homepage
              for configuration suggestions.

       -p, --port=<num>
              Listen on TCP port <num>, the default is  port  11211.  0  means

       -U, --udp-port=<num>
              Listen on UDP port <num>, the default is port 0, which is off.

       -M, --disable-evictions
              Disable  automatic  removal  of items from the cache when out of
              memory.  Additions will not be possible until adequate space  is
              freed up.

       -r, --enable-coredumps
              Raise the core file size limit to the maximum allowable.

       -f, --slab-growth-factor=<factor>
              Use <factor> as the multiplier for computing the sizes of memory
              chunks that items are stored in. A lower  value  may  result  in
              less  wasted  memory  depending  on  the  total amount of memory
              available and the distribution of item sizes.   The  default  is

       -n, --slab-min-size=<size>
              Allocate  a minimum of <size> bytes for the item key, value, and
              flags. The default is 48. If you have a lot of  small  keys  and
              values,  you can get a significant memory efficiency gain with a
              lower value. If you use a high chunk growth factor (-f  option),
              on  the other hand, you may want to increase the size to allow a
              bigger percentage of your items  to  fit  in  the  most  densely
              packed (smallest) chunks.

       -C, --disable-cas
              Disable  the  use  of  CAS  (and  reduce  the per-item size by 8

       -h, --help
              Show the version of memcached and a summary of options.

       -v, --verbose
              Be verbose during the event loop; print out errors and warnings.

       -vv    Be even more verbose; same as -v but also print client  commands
              and responses.

       -vvv   Be  extremely verbose; same of the above and also print internal
              state transitions.

       -i, --license
              Print memcached and libevent licenses.

       -P, --pidfile=<filename>
              Print pidfile to <filename>, only used under -d option.

       -t, --threads=<threads>
              Number of threads to use  to  process  incoming  requests.  This
              option  is only meaningful if memcached was compiled with thread
              support enabled. It is typically not useful to set  this  higher
              than  the number of CPU cores on the memcached server. Setting a
              high number (64 or more) of worker threads is  not  recommended.
              The default is 4.

       -D <char>
              Use  <char>  as the delimiter between key prefixes and IDs. This
              is used for per-prefix  stats  reporting.  The  default  is  ":"
              (colon). If this option is specified, stats collection is turned
              on automatically; if not, then it may be turned  on  by  sending
              the "stats detail on" command to the server.

       -L, --enable-largepages
              Try  to  use  large  memory pages (if available). Increasing the
              memory page size could reduce  the  number  of  TLB  misses  and
              improve  the  performance.  In order to get large pages from the
              OS, memcached will allocate the total item-cache  in  one  large
              chunk. Only available if supported on your OS.

       -b, --listen-backlog=<num>
              Set the backlog queue limit to <num> connections. The default is

       -B, --protocol=<proto>
              Specify the binding protocol to use.   By  default,  the  server
              will  autonegotiate  client  connections.  By using this option,
              you can specify  the  protocol  clients  must  speak.   Possible
              options  are  "auto"  (the  default,  autonegotiation behavior),
              "ascii" and "binary".

       -I, --max-item-size=<size>
              Override the default size of each slab page. The default size is
              1mb.  Default value for this parameter is 1m, minimum is 1k, max
              is 1G (1024 * 1024 * 1024).  Adjusting this  value  changes  the
              item size limit.

       -S, --enable-sasl
              Turn  on  SASL authentication. This option is only meaningful if
              memcached was compiled with SASL support enabled.

       -F, --disable-flush-all
              Disables the "flush_all" command.  The  cmd_flush  counter  will
              increment,  but  clients  will  receive an error message and the
              flush will not occur.

       -X, --disable-dumping
              Disables the "stats cachedump" and "lru_crawler  metadump"  com-

       -o, --extended=<options>
              Comma separated list of extended or experimental options. See -h
              or wiki for up to date list.

       -V, --version
              print version and exit

       memcached package for Solaris (service/memcached) includes files neces-
       sary  to  register  with  the  Service Management Facility described in
       SMF(7). The following procedure describes the  steps  to  automate  the
       service management using memcached.

           1.     Add  other  parameters to be passed to the memcached service

                  example: specify the server to use 1024 MB of memory

                    example% svccfg
                    svc:> select memcached
                    svc:/application/database/memcached> setprop memcached/options=("-m" "1024")
                    svc:/application/database/memcached> quit
                    example% svcadm refresh memcached

           Note -

             The arguments cannot be passed as a single string  because  of  a
             limitation in svccfg.

           2.     Enable memcached .

                    example% svcadm enable memcached

                  The state of the service instance changes to online, and the
                  memcached service instance must be started:

                    example% svcs memcached
                    STATE          STIME    FMRI
                    online          1:19:15 svc:/application/database/memcached:default

           3.     To disable shutdown and automatic restart of memcached  ser-
                  vice instance,

                    example% svcadm disable memcached

       You can use RBAC(7) to authorize otherwise non-privileged users to man-
       age memcached services.  To let a user named  myuser  change  memcached
       value properties and manage memcached service states, add the following
       line to /etc/user_attr:

         myuser::::type=role;profiles=Memcached Administration,All

       The memcached package consists of the memcached server  and  man  pages
       for the server.

       Client libraries can be made available by installing other packages.

       The  memcached  server  is  based on the memcached open-source software
       available from http://www.danga.com/memcached/.

       When the memcached server is started, it listens for  network  requests
       on  a  TCP  port and/or a UDP port. It is important for the security of
       the network that you protect this port, for example, by blocking access
       to this port in a firewall.

       The default TCP port number to use is 11211.

       You  may use the -p option to set another TCP port number.  There is no
       default UDP port number. You can use the -U option to set  a  UDP  port

       If  you  are running memcached on a server with multiple network inter-
       faces, you can restrict vulnerability by binding memcached to a  single
       interface by using the -l option.

       Caution -

         Note  that  memcached  was  designed  for speed and not for security.
         There is no authentication of requests that go in  to  the  memcached
         servers,  and  communication  is not encrypted. The network that your
         memcached servers and  clients  run  within  should  be  safe-guarded
         against network attacks.

       The  memcached daemon is copyright Danga Interactive and is distributed
       under the BSD license. Note that  daemon  clients  are  licensed  sepa-

       See attributes(7) for descriptions of the following attributes:

       |Availability   | service/memcached |
       |Stability      | Uncommitted       |

       The README file that comes with memcached



       The  memcached daemon was written by Anatoly Vorobey <mellon@pobox.com>
       and Brad Fitzpatrick <brad@danga.com> and the rest of the crew of Danga
       Interactive https://www.danga.com

       Source  code  for open source software components in Oracle Solaris can
       be found at https://www.oracle.com/downloads/opensource/solaris-source-

       This     software     was    built    from    source    available    at
       https://github.com/oracle/solaris-userland.   The  original   community
       source    was    downloaded    from     http://memcached.org/files/mem-

       Further information about this software can be found on the open source
       community website at http://memcached.org/.

                                April 11, 2005                    MEMCACHED(8)