Skip to content

Commit

Permalink
Merge pull request #2200 from mabel-dev/#1954-3
Browse files Browse the repository at this point in the history
  • Loading branch information
joocer authored Jan 4, 2025
2 parents c7f4e23 + f02fd1f commit acba698
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion opteryx/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__build__ = 951
__build__ = 952

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
8 changes: 6 additions & 2 deletions tests/storage/test_cache_memcached.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def test_memcached_cache():
from opteryx import CacheManager
from opteryx.managers.cache import MemcachedCache
from opteryx.shared import BufferPool
from opteryx import register_store
from opteryx.connectors import GcpCloudStorageConnector

register_store("opteryx", GcpCloudStorageConnector)

cache = MemcachedCache()
#cache._server.flush_all()
Expand All @@ -37,7 +41,7 @@ def test_memcached_cache():
for i in range(10):
cur = conn.cursor()
time.sleep(0.01)
cur.execute("SELECT count(*) FROM testdata.flat.ten_files;")
cur.execute("SELECT count(*) FROM opteryx.ten_files;")

print(f"hits: {cache.hits}, misses: {cache.misses}, skips: {cache.skips}, errors: {cache.errors}, sets: {cache.sets}")

Expand All @@ -47,7 +51,7 @@ def test_memcached_cache():
buffer.reset()

cur = conn.cursor()
cur.execute("SELECT count(*) FROM testdata.flat.ten_files;")
cur.execute("SELECT count(*) FROM opteryx.ten_files;")

stats = cur.stats

Expand Down
10 changes: 7 additions & 3 deletions tests/storage/test_cache_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@ def test_redis_cache():
from opteryx import CacheManager
from opteryx.managers.cache import RedisCache
from opteryx.shared import BufferPool
from opteryx import register_store
from opteryx.connectors import GcpCloudStorageConnector

register_store("opteryx", GcpCloudStorageConnector)

cache = RedisCache()
opteryx.set_cache_manager(CacheManager(cache_backend=cache))

# read the data once, this should populate the cache if it hasn't already
cur = opteryx.query("SELECT * FROM testdata.flat.ten_files;")
stats = cur.stats
cur = opteryx.query("SELECT * FROM opteryx.ten_files;")
cur.fetchall()

buffer = BufferPool()
buffer.reset()

# read the data a second time, this should hit the cache
cur = opteryx.query("SELECT * FROM testdata.flat.ten_files;")
cur = opteryx.query("SELECT * FROM opteryx.ten_files;")

assert cache.hits > 0
assert cache.misses < 12
Expand Down
10 changes: 7 additions & 3 deletions tests/storage/test_cache_valkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,23 @@ def test_valkey_cache():
from opteryx import CacheManager
from opteryx.managers.cache import ValkeyCache
from opteryx.shared import BufferPool
from opteryx import register_store
from opteryx.connectors import GcpCloudStorageConnector

register_store("opteryx", GcpCloudStorageConnector)

cache = ValkeyCache()
opteryx.set_cache_manager(CacheManager(cache_backend=cache))

# read the data once, this should populate the cache if it hasn't already
cur = opteryx.query("SELECT * FROM testdata.flat.ten_files;")
stats = cur.stats
cur = opteryx.query("SELECT * FROM opteryx.ten_files;")
cur.fetchall()

buffer = BufferPool()
buffer.reset()

# read the data a second time, this should hit the cache
cur = opteryx.query("SELECT * FROM testdata.flat.ten_files;")
cur = opteryx.query("SELECT * FROM opteryx.ten_files;")

assert cache.hits > 0, cache.hits
assert cache.misses < 12
Expand Down

0 comments on commit acba698

Please sign in to comment.