Skip to content

Commit

Permalink
Merge pull request #874 from hackforla/feat-cache-improvements
Browse files Browse the repository at this point in the history
Feat cache improvements
  • Loading branch information
mattyweb authored Dec 17, 2020
2 parents 549c508 + 309aac5 commit 3085579
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create_release_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run: |
echo GITHUB_CODE_VERSION=${{ env.BRANCH_NAME }} >> server/api/.env
echo GITHUB_SHA=${{ github.sha }} >> server/api/.env
echo DEBUG=True
echo DEBUG=True >> server/api/.env
- name: Build and Push Image to Docker Hub
uses: docker/build-push-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion server/api/code/lacity_data_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


def get_app():
app = FastAPI(title="LA City 311 Data API", debug=DEBUG)
app = FastAPI(title="LA 311 Data API", debug=DEBUG)

db.init_app(app)
app.include_router(index.router)
Expand Down
6 changes: 3 additions & 3 deletions server/api/code/lacity_data_api/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
cache = RedisCache(
endpoint=config.CACHE_ENDPOINT,
serializer=serializers.PickleSerializer(),
timeout=3, # lowering to 1
pool_min_size=4, # raising min and max
pool_max_size=12,
timeout=10, # lowering to 1
pool_min_size=5, # raising min and max
pool_max_size=20,
)
8 changes: 2 additions & 6 deletions server/api/code/lacity_data_api/routers/status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import os

from fastapi import APIRouter

Expand Down Expand Up @@ -27,18 +28,13 @@ async def reset_cache():
description="Provides the status of backend systems")
async def check_status_type(status_type: StatusTypes):
if status_type == StatusTypes.api:

cache_items = await status.get_cache_keys()
if len(cache_items) == 0:
await utilities.build_cache()

return {
'currentTime': datetime.datetime.now(),
'lastPulled': await status.get_last_updated(),
'stage': STAGE,
'version': GITHUB_CODE_VERSION,
'gitSha': GITHUB_SHA,
'cachedItems': len(cache_items)
'process': os.getpid()
}

if status_type == StatusTypes.database:
Expand Down

0 comments on commit 3085579

Please sign in to comment.