diff --git a/pycassa/system_manager.py b/pycassa/system_manager.py index d1212315..888e90a8 100644 --- a/pycassa/system_manager.py +++ b/pycassa/system_manager.py @@ -277,6 +277,7 @@ def create_column_family(self, keyspace, name, super=False, compaction_strategy_options=None, row_cache_keys_to_save=None, compression_options=None, + caching=None, comment=None): """ @@ -357,6 +358,9 @@ def create_column_family(self, keyspace, name, super=False, ``DeflateCompressor``, or a custom compressor, and ``chunk_length_kb``, which must be a power of 2. + caching Specify caching policy, one of + `all`, `keys_only`, `rows_only` or + `none`, defaults to `keys_only`. comment A human readable comment describing the column family ================================ ===================================== @@ -364,6 +368,9 @@ def create_column_family(self, keyspace, name, super=False, .. versionadded:: 1.4.0 The `column_validation_classes` parameter. + .. versionadded:: 1.7.0 + The `caching` parameter. + """ self._conn.set_keyspace(keyspace) @@ -402,6 +409,7 @@ def create_column_family(self, keyspace, name, super=False, self._cfdef_assign(compaction_strategy_options, cfdef, 'compaction_strategy_options') self._cfdef_assign(row_cache_keys_to_save, cfdef, 'row_cache_keys_to_save') self._cfdef_assign(compression_options, cfdef, 'compression_options') + self._cfdef_assign(caching, cfdef, 'caching') self._system_add_column_family(cfdef) @@ -439,6 +447,7 @@ def alter_column_family(self, keyspace, column_family, compaction_strategy_options=None, row_cache_keys_to_save=None, compression_options=None, + caching=None, comment=None): """ @@ -464,6 +473,7 @@ def alter_column_family(self, keyspace, column_family, self._cfdef_assign(compaction_strategy_options, cfdef, 'compaction_strategy_options') self._cfdef_assign(row_cache_keys_to_save, cfdef, 'row_cache_keys_to_save') self._cfdef_assign(compression_options, cfdef, 'compression_options') + self._cfdef_assign(caching, cfdef, 'caching') self._cfdef_assign(merge_shards_chance, cfdef, 'merge_shards_chance') self._cfdef_assign(comment, cfdef, 'comment') diff --git a/tests/test_system_manager.py b/tests/test_system_manager.py index c47f7638..0ca2de30 100644 --- a/tests/test_system_manager.py +++ b/tests/test_system_manager.py @@ -119,3 +119,22 @@ def test_caching_pre_11(self): assert_equal(cf1._cfdef.key_cache_size, 200) assert_equal(cf1._cfdef.row_cache_save_period_in_seconds, 4) assert_equal(cf1._cfdef.key_cache_save_period_in_seconds, 4) + + def test_caching_post_11(self): + version = tuple( + [int(v) for v in sys._conn.describe_version().split('.')]) + if version < (19, 30, 0): + raise SkipTest('CF caching policy not yet supported.') + sys.create_column_family(TEST_KS, 'CachedCF11') + pool = ConnectionPool(TEST_KS) + cf = ColumnFamily(pool, 'CachedCF11') + assert_equal(cf._cfdef.caching, 'KEYS_ONLY') + sys.alter_column_family(TEST_KS, 'CachedCF11', caching='all') + cf = ColumnFamily(pool, 'CachedCF11') + assert_equal(cf._cfdef.caching, 'ALL') + sys.alter_column_family(TEST_KS, 'CachedCF11', caching='rows_only') + cf = ColumnFamily(pool, 'CachedCF11') + assert_equal(cf._cfdef.caching, 'ROWS_ONLY') + sys.alter_column_family(TEST_KS, 'CachedCF11', caching='none') + cf = ColumnFamily(pool, 'CachedCF11') + assert_equal(cf._cfdef.caching, 'NONE')