Skip to content
Browse files

add the new `caching` argument to CF related functions in system_manager

  • Loading branch information...
1 parent b7d216f commit 02a7c3885b0fb6b913152db750366269609b436d @hannosch hannosch committed with thobbs Jul 3, 2012
Showing with 29 additions and 0 deletions.
  1. +10 −0 pycassa/system_manager.py
  2. +19 −0 tests/test_system_manager.py
View
10 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,13 +358,19 @@ 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
================================ =====================================
.. 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')
View
19 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')

0 comments on commit 02a7c38

Please sign in to comment.
Something went wrong with that request. Please try again.