diff --git a/synapse/lib/cache.py b/synapse/lib/cache.py
index 788dc81b5..6c3487c41 100644
--- a/synapse/lib/cache.py
+++ b/synapse/lib/cache.py
@@ -428,5 +428,15 @@ class RefDict:
         with self.lock:
             return [self._pop(k) for k in keys]
 
+    def clear(self):
+        with self.lock:
+            self.vals.clear()
+            self.refs.clear()
+
+    def __contains__(self, item):
+        with self.lock:
+            return item in self.vals
+
     def __len__(self):
-        return len(self.vals)
+        with self.lock:
+            return len(self.vals)

dynamically disabling caching on a cortex seems broken
Trigger with setConfOpt("caching",0) 
```
Traceback (most recent call last):
  File "/home/autouser/git/synapse/synapse/eventbus.py", line 154, in dist
    ret.append( func( event ) )
  File "/home/autouser/git/synapse/synapse/lib/config.py", line 135, in callback
    return func(valu)
  File "/home/autouser/git/synapse/synapse/cores/common.py", line 643, in _onSetCaching
    self.cache_byiden.clear()
AttributeError: 'RefDict' object has no attribute 'clear'
```
diff --git a/synapse/tests/test_cache.py b/synapse/tests/test_cache.py
index 524d70d61..0c6eb36bf 100644
--- a/synapse/tests/test_cache.py
+++ b/synapse/tests/test_cache.py
@@ -1,9 +1,6 @@
-import unittest
-import threading
 import collections
 
 import synapse.lib.cache as s_cache
-import synapse.cortex as s_cortex
 
 from synapse.tests.common import *
 
@@ -220,3 +217,54 @@ class CacheTest(SynTest):
         od = s_cache.OnDem()
         with self.raises(KeyError) as cm:
             od.get('foo')
+
+    def test_refdict(self):
+        rd = s_cache.RefDict()
+        # puts, pop, get, clear
+        # Put an item in a few times
+        self.eq(rd.put('syn:val', 123), 123)
+        self.true('syn:val' in rd.vals)
+        self.eq(rd.refs.get('syn:val'), 1)
+        rd.put('syn:val', 123)
+        self.true('syn:val' in rd.vals)
+        self.eq(rd.refs.get('syn:val'), 2)
+        # Get values out, ensure defaults of None are returned
+        self.eq(rd.get('syn:val'), 123)
+        self.none(rd.get('syn:noval'))
+        # Pop an item out until its gone from the refdict
+        # XXX Unclear if the following none() is a desired behavior
+        # XXX for pop on a existing value which still has refs > 0
+        self.none(rd.pop('syn:val'))
+        self.eq(rd.refs.get('syn:val'), 1)
+        self.eq(rd.pop('syn:val'), 123)
+        self.false('syn:val' in rd.refs)
+        self.false('syn:val' in rd.vals)
+
+        kvs = (
+            ('foo', 'bar'),
+            ('knight', 'ni'),
+            ('clown', 'pennywise'),
+            ('inet:netuser', 'vertex.link/pennywise')
+        )
+        # puts
+        rd.puts(kvs)
+        # validate setdefault behavior
+        self.eq(rd.put('foo', 'baz'), 'bar')
+        self.eq(rd.refs.get('foo'), 2)
+        # __len__
+        self.eq(len(rd), 4)
+        # __contains__
+        self.true('clown' in rd)
+        self.false('badger' in rd)
+        # gets
+        r = rd.pops(['foo', 'knight', 'syn:novalu'])
+        # self.eq(r, ['bar', 'ni', None])
+        # XXX This is None, ni, None because of the weird pop() behavior.
+        self.eq(r, [None, 'ni', None])
+        self.true('foo' in rd)
+        self.true('knight' not in rd)
+        self.eq(len(rd), 3)
+        # Clear
+        rd.clear()
+        self.eq(len(rd), 0)
+        self.eq(len(rd.refs), 0)
diff --git a/synapse/tests/test_cortex.py b/synapse/tests/test_cortex.py
index 24707a38d..00837e4e8 100644
--- a/synapse/tests/test_cortex.py
+++ b/synapse/tests/test_cortex.py
@@ -1279,6 +1279,26 @@ class CortexTest(SynTest):
             self.true(tufo0[1].get('.new'))
             self.false(tufo1[1].get('.new'))
 
+    def test_cortex_caching_disable(self):
+
+        with s_cortex.openurl('ram://') as core:
+
+            core.setConfOpt('caching', 1)
+
+            tufo = core.formTufoByProp('foo', 'bar')
+
+            self.nn(core.cache_byiden.get(tufo[0]))
+            self.nn(core.cache_bykey.get(('foo', 'bar', 1)))
+            self.nn(core.cache_byprop.get(('foo', 'bar')))
+            self.eq(len(core.cache_fifo), 1)
+
+            core.setConfOpt('caching', 0)
+
+            self.none(core.cache_byiden.get(tufo[0]))
+            self.none(core.cache_bykey.get(('foo', 'bar', 1)))
+            self.none(core.cache_byprop.get(('foo', 'bar')))
+            self.eq(len(core.cache_fifo), 0)
+
     def test_cortex_reqstor(self):
         with s_cortex.openurl('ram://') as core:
             self.raises(BadPropValu, core.formTufoByProp, 'foo:bar', True)

pip install -e .
parse_log_pytest
pytest
nose coverage pytest
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
certifi==2021.5.30
cffi==1.15.1
coverage==6.2
cryptography==40.0.2
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1631916693255/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
lmdb==1.6.2
more-itertools @ file:///tmp/build/80754af9/more-itertools_1637733554872/work
msgpack-python==0.5.6
nose==1.3.7
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
pluggy @ file:///tmp/build/80754af9/pluggy_1615976315926/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pycparser==2.21
pyOpenSSL==23.2.0
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
pytest==6.2.4
-e git+https://github.com/vertexproject/synapse.git@82966be7ae8b614ae15eb42b3bf7b8306e5604bf#egg=synapse
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
tornado==6.1
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
xxhash==3.2.0
zipp @ file:///tmp/build/80754af9/zipp_1633618647012/work

name: synapse
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=21.4.0=pyhd3eb1b0_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - importlib-metadata=4.8.1=py36h06a4308_0
  - importlib_metadata=4.8.1=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - more-itertools=8.12.0=pyhd3eb1b0_0
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pip=21.2.2=py36h06a4308_0
  - pluggy=0.13.1=py36h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pytest=6.2.4=py36h06a4308_2
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - toml=0.10.2=pyhd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.6.0=pyhd3eb1b0_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - cffi==1.15.1
      - coverage==6.2
      - cryptography==40.0.2
      - lmdb==1.6.2
      - msgpack-python==0.5.6
      - nose==1.3.7
      - pycparser==2.21
      - pyopenssl==23.2.0
      - tornado==6.1
      - xxhash==3.2.0
prefix: /opt/conda/envs/synapse

synapse/tests/test_cache.py::CacheTest::test_refdict synapse/tests/test_cortex.py::CortexTest::test_cortex_caching_disable
synapse/tests/test_cache.py::CacheTest::test_cache_clearing synapse/tests/test_cache.py::CacheTest::test_cache_defval synapse/tests/test_cache.py::CacheTest::test_cache_fini synapse/tests/test_cache.py::CacheTest::test_cache_fixed synapse/tests/test_cache.py::CacheTest::test_cache_magic synapse/tests/test_cache.py::CacheTest::test_cache_miss synapse/tests/test_cache.py::CacheTest::test_cache_set_maxtime synapse/tests/test_cache.py::CacheTest::test_cache_timeout synapse/tests/test_cache.py::CacheTest::test_cache_tufo synapse/tests/test_cache.py::CacheTest::test_cache_tufo_prop synapse/tests/test_cache.py::CacheTest::test_keycache_lookup synapse/tests/test_cache.py::CacheTest::test_ondem_add synapse/tests/test_cache.py::CacheTest::test_ondem_class synapse/tests/test_cortex.py::CortexTest::test_cortex_addmodel synapse/tests/test_cortex.py::CortexTest::test_cortex_by_type synapse/tests/test_cortex.py::CortexTest::test_cortex_bytype synapse/tests/test_cortex.py::CortexTest::test_cortex_caching synapse/tests/test_cortex.py::CortexTest::test_cortex_caching_add_tufo synapse/tests/test_cortex.py::CortexTest::test_cortex_caching_atlimit synapse/tests/test_cortex.py::CortexTest::test_cortex_caching_del_tufo synapse/tests/test_cortex.py::CortexTest::test_cortex_caching_new synapse/tests/test_cortex.py::CortexTest::test_cortex_caching_oneref synapse/tests/test_cortex.py::CortexTest::test_cortex_caching_set synapse/tests/test_cortex.py::CortexTest::test_cortex_caching_tags synapse/tests/test_cortex.py::CortexTest::test_cortex_caching_under_limit synapse/tests/test_cortex.py::CortexTest::test_cortex_choptag synapse/tests/test_cortex.py::CortexTest::test_cortex_comp synapse/tests/test_cortex.py::CortexTest::test_cortex_dict synapse/tests/test_cortex.py::CortexTest::test_cortex_enforce synapse/tests/test_cortex.py::CortexTest::test_cortex_events synapse/tests/test_cortex.py::CortexTest::test_cortex_fire_set synapse/tests/test_cortex.py::CortexTest::test_cortex_getbytag synapse/tests/test_cortex.py::CortexTest::test_cortex_ingest synapse/tests/test_cortex.py::CortexTest::test_cortex_isnew synapse/tests/test_cortex.py::CortexTest::test_cortex_lmdb synapse/tests/test_cortex.py::CortexTest::test_cortex_local synapse/tests/test_cortex.py::CortexTest::test_cortex_minmax synapse/tests/test_cortex.py::CortexTest::test_cortex_minmax_epoch synapse/tests/test_cortex.py::CortexTest::test_cortex_modlrevs synapse/tests/test_cortex.py::CortexTest::test_cortex_modlvers synapse/tests/test_cortex.py::CortexTest::test_cortex_module synapse/tests/test_cortex.py::CortexTest::test_cortex_module_datamodel_migration synapse/tests/test_cortex.py::CortexTest::test_cortex_module_datamodel_migration_persistent synapse/tests/test_cortex.py::CortexTest::test_cortex_norm_fail synapse/tests/test_cortex.py::CortexTest::test_cortex_notguidform synapse/tests/test_cortex.py::CortexTest::test_cortex_ram synapse/tests/test_cortex.py::CortexTest::test_cortex_ramhost synapse/tests/test_cortex.py::CortexTest::test_cortex_ramtyperange synapse/tests/test_cortex.py::CortexTest::test_cortex_reqstor synapse/tests/test_cortex.py::CortexTest::test_cortex_rev0 synapse/tests/test_cortex.py::CortexTest::test_cortex_savefd synapse/tests/test_cortex.py::CortexTest::test_cortex_seed synapse/tests/test_cortex.py::CortexTest::test_cortex_seq synapse/tests/test_cortex.py::CortexTest::test_cortex_splicefd synapse/tests/test_cortex.py::CortexTest::test_cortex_splicepump synapse/tests/test_cortex.py::CortexTest::test_cortex_splices synapse/tests/test_cortex.py::CortexTest::test_cortex_splices_errs synapse/tests/test_cortex.py::CortexTest::test_cortex_sqlite3 synapse/tests/test_cortex.py::CortexTest::test_cortex_stats synapse/tests/test_cortex.py::CortexTest::test_cortex_tag_ival synapse/tests/test_cortex.py::CortexTest::test_cortex_tagform synapse/tests/test_cortex.py::CortexTest::test_cortex_tags synapse/tests/test_cortex.py::CortexTest::test_cortex_tlib_persistence synapse/tests/test_cortex.py::CortexTest::test_cortex_tufo_by_default synapse/tests/test_cortex.py::CortexTest::test_cortex_tufo_del synapse/tests/test_cortex.py::CortexTest::test_cortex_tufo_list synapse/tests/test_cortex.py::CortexTest::test_cortex_tufo_pop synapse/tests/test_cortex.py::CortexTest::test_cortex_tufo_setprop synapse/tests/test_cortex.py::CortexTest::test_cortex_tufo_setprops synapse/tests/test_cortex.py::CortexTest::test_cortex_tufo_tag synapse/tests/test_cortex.py::CortexTest::test_cortex_xact_deadlock
synapse/lib/cache.py
synapse/lib/cache.py