Skip to content

Commit

Permalink
add the new caching argument to CF related functions in system_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch authored and thobbs committed Jul 17, 2012
1 parent b7d216f commit 02a7c38
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pycassa/system_manager.py
Expand Up @@ -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):

"""
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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):

"""
Expand All @@ -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')

Expand Down
19 changes: 19 additions & 0 deletions tests/test_system_manager.py
Expand Up @@ -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.