(dev/core#174) Memcache(d) - Updates to comply with PSR-16
authorTim Otten <totten@civicrm.org>
Tue, 26 Jun 2018 23:10:27 +0000 (16:10 -0700)
committerTim Otten <totten@civicrm.org>
Sat, 30 Jun 2018 20:44:26 +0000 (13:44 -0700)
commitfbbfd6dd52f46147a42dc2f1c30d8c27b670a1fe
tree3b66f9d7c522ca9b9b1f3901742248467a88912c
parent784dd9c4af443a34a95682ecfda7e44bd69481ae
(dev/core#174) Memcache(d) - Updates to comply with PSR-16

There are two drivers, `CRM_Utils_Memcache` and `CRM_Utils_Memcached`.  It's
nice to update them in tandem (with similar design decisions).  If an admin
admin is experimenting/debugging, this consistency makes it easier to switch
between drivers.  (Cache data written by one driver can be read by the other
driver.)

In addition to the standard PSR-16-style changes, there are a couple changes
in how data is formatted when written to memcache:

* To allow support for targetted `flush()`ing (one prefix at a time), we update
  the naming convention per https://github.com/memcached/memcached/wiki/ProgrammingTricks#deleting-by-namespace
  This means that a typical key includes a bucket-revision code:
    * BEFORE: `<site-prefix>/<bucket-prefix>/<item-key>` (`dmaster/default/mykey`)
    * AFTER: `<site-prefix>/<bucket-prefix>/<bucket-revision>/<item-key>` (`dmaster/default/5b33011fea555/mykey`)
* Values are `serialize()`d. This resolves an ambiguity where `Memcache::get()`
  does not let us know if it returns `FALSE` because there's an error because
  that's the stored value. By serializing, those scenarios can be distinguished.
    * `get(...) === FALSE` means "item was not found"
    * `get(...) === serialize(FALSE)` means "item was found with value FALSE"
CRM/Utils/Cache/Memcache.php
CRM/Utils/Cache/Memcached.php