Reference

show cache

Show cache status.

Description Jump to heading

Query the Runtime API with show cache to display cache information.

Examples Jump to heading

Create a cache in your load balancer config file and attach the cache to a backend:

haproxy
cache mycache
total-max-size 4095 # MB
max-object-size 10000 # bytes
max-age 30 # seconds
backend be_api
# Get from cache / put in cache
http-request cache-use mycache
http-response cache-store mycache
# server list
server s1 172.25.0.10:8080 check
haproxy
cache mycache
total-max-size 4095 # MB
max-object-size 10000 # bytes
max-age 30 # seconds
backend be_api
# Get from cache / put in cache
http-request cache-use mycache
http-response cache-store mycache
# server list
server s1 172.25.0.10:8080 check

Use socat to query the load balancer Runtime API:

nix
echo "show cache" | \
sudo socat stdio tcp4-connect:127.0.0.1:9999
nix
echo "show cache" | \
sudo socat stdio tcp4-connect:127.0.0.1:9999
output
text
0x7fcad7c9603a: api_cache (shctx:0x7fcad7c96000, available blocks:4193280)
0x7fcad7c960c0 hash:3075548050 size:363 (1 blocks), refcount:0, expire:10
output
text
0x7fcad7c9603a: api_cache (shctx:0x7fcad7c96000, available blocks:4193280)
0x7fcad7c960c0 hash:3075548050 size:363 (1 blocks), refcount:0, expire:10

These two lines of output are explained in the tables below.

The first line breaks down as follows:

output
text
0x7fcad7c9603a: api_cache (shctx:0x7fcad7c96000, available blocks:4193280)
output
text
0x7fcad7c9603a: api_cache (shctx:0x7fcad7c96000, available blocks:4193280)
Output| Description
-----|-----
`0x7fcad7c9603a:`| pointer to the cache structure
`api\_cache`| cache name
`shctx:0x7fcad7c96000`| pointer to the mmap area (shctx)
`available blocks:4193280`| number of blocks available for reuse in the shctx
Output| Description
-----|-----
`0x7fcad7c9603a:`| pointer to the cache structure
`api\_cache`| cache name
`shctx:0x7fcad7c96000`| pointer to the mmap area (shctx)
`available blocks:4193280`| number of blocks available for reuse in the shctx

The second line of output breaks down as:

output
text
0x7fcad7c960c0 hash:3075548050 vary:0x0011223344556677 size:363 (1 blocks), refcount:0, expire:10
output
text
0x7fcad7c960c0 hash:3075548050 vary:0x0011223344556677 size:363 (1 blocks), refcount:0, expire:10
Output| Description
-----|-----
`0x7fcad7c960c0`| pointer to the cache entry
`hash:3075548050`| first 32 bits of the hash
`vary:0x0011223344556677`| secondary hash of the entry in case of vary. Available as of version `2.4r1`.
`size:363`| size of the object in bytes
`(1 blocks)`| number of blocks used for the object
`refcount:0`| number of transactions using the entry
`expire:10`| expiration time
Output| Description
-----|-----
`0x7fcad7c960c0`| pointer to the cache entry
`hash:3075548050`| first 32 bits of the hash
`vary:0x0011223344556677`| secondary hash of the entry in case of vary. Available as of version `2.4r1`.
`size:363`| size of the object in bytes
`(1 blocks)`| number of blocks used for the object
`refcount:0`| number of transactions using the entry
`expire:10`| expiration time

See also Jump to heading

Do you have any suggestions on how we can improve the content of this page?