+void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr,
+ int pos,
+ const char *syntax, const char *elementSetName,
+ const char *schema,
+ Z_SRW_diagnostic *diag)
+{
+ record_cache_add(r, npr, pos, syntax, elementSetName, schema, diag);
+#if HAVE_LIBMEMCACHED_MEMCACHED_H
+ if (r->connection->mc_st &&
+ !diag && npr->which == Z_NamePlusRecord_databaseRecord &&
+ npr->u.databaseRecord->which == Z_External_octet)
+ {
+ WRBUF k = wrbuf_alloc();
+ uint32_t flags = 0;
+ memcached_return_t rc;
+ time_t expiration = 36000;
+
+ wrbuf_write(k, wrbuf_buf(r->mc_key), wrbuf_len(r->mc_key));
+ wrbuf_printf(k, ";%d;%s;%s;%s", pos,
+ syntax ? syntax : "",
+ elementSetName ? elementSetName : "",
+ schema ? schema : "");
+ rc = memcached_set(r->connection->mc_st,
+ wrbuf_buf(k),wrbuf_len(k),
+ npr->u.databaseRecord->u.octet_aligned->buf,
+ npr->u.databaseRecord->u.octet_aligned->len,
+ expiration, flags);
+
+ yaz_log(YLOG_LOG, "Store record key=%s rc=%u %s",
+ wrbuf_cstr(k), (unsigned) rc,
+ memcached_last_error_message(r->connection->mc_st));
+ wrbuf_destroy(k);
+ }
+#endif
+}
+
+