0

I have setup Redis as a caching mechanism on my server with a Wordpress site. Basically on each request I check if a cache of the page exists and then I show the cache.

I'm using Predis (https://github.com/nrk/predis) as an interface to the redis database.

When I get the info from the usage of Redis however, I only see 1 key used in the system:

used_memory:103810376
used_memory_human:99.00M
used_memory_rss:106680320
used_memory_peak:222011768
used_memory_peak_human:211.73M
mem_fragmentation_ratio:1.03
mem_allocator:jemalloc-2.2.5
loading:0
aof_enabled:0
changes_since_last_save:8
bgsave_in_progress:0
last_save_time:1396168319
bgrewriteaof_in_progress:0
total_connections_received:726918
total_commands_processed:1240245
expired_keys:22
evicted_keys:0
keyspace_hits:1158841
keyspace_misses:699
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:21712
vm_enabled:0
role:master
db0:keys=1,expires=0

How could this be? I expect to see more keys listed, as each cached copy of the html of a page should have it's own key?

What am I missing here?

Patrick Steenks
  • 612
  • 1
  • 11
  • 24

1 Answers1

3

Without looking at the technical implementation, it could be several things.

1) The pages didn't get a hit, so they are not in the cache

2) The keys expired already

3) The mechanism uses for example a HSET , where you can have N key/values registered under 1 main key. You can check this by using the TYPE redis command on the single key you've got.

Tw Bert
  • 3,659
  • 20
  • 28
  • Ah, great, that points me in the right direction. We are indeed using hset in de connection to redis, but I wasn't aware that N key/value pairs can be registered under this. What is the main benefit of using HSET over SET? – Patrick Steenks Mar 30 '14 at 11:23
  • Hashes were added in Redis 1.4 (quite a while back). They were intended to have an object store inside redis, where you can access the different data members individually. But (like anything in Redis), you can use it for all kinds of purposes. We prefer `HSET`'s over plain `SET`/`GET` to keep things organized. This is a choice, because a `HSET` has a slight overhead (two dict lookups instead of one; the key plus the member). You can read more about redis datatypes [here](http://redis.io/topics/data-types). If you plan to use `SORT`, read carefully. – Tw Bert Mar 30 '14 at 11:38