Examples#
Index > ElastiCache > Examples
Auto-generated documentation for ElastiCache type annotations stubs module types-aiobotocore-elasticache.
Client#
Implicit type annotations#
Can be used with types-aiobotocore[elasticache]
package installed.
Write your ElastiCache
code as usual,
type checking and code completion should work out of the box.
Client method usage example#
# ElastiCacheClient usage example
from aiobotocore.session import get_session
session = get_session()
async with session.create_client("elasticache") as client: # (1)
result = await client.add_tags_to_resource() # (2)
- client: ElastiCacheClient
- result: TagListMessageTypeDef
Paginator usage example#
# DescribeCacheClustersPaginator usage example
from aiobotocore.session import get_session
session = get_session()
async with session.create_client("elasticache") as client: # (1)
paginator = client.get_paginator("describe_cache_clusters") # (2)
async for item in paginator.paginate(...):
print(item) # (3)
- client: ElastiCacheClient
- paginator: DescribeCacheClustersPaginator
- item: CacheClusterMessageTypeDef
Waiter usage example#
# CacheClusterAvailableWaiter usage example
from aiobotocore.session import get_session
session = get_session()
async with session.create_client("elasticache") as client: # (1)
waiter = client.get_waiter("cache_cluster_available") # (2)
await waiter.wait(...)
- client: ElastiCacheClient
- waiter: CacheClusterAvailableWaiter
Explicit type annotations#
With types-aiobotocore-lite[elasticache]
or a standalone types_aiobotocore_elasticache
package, you have to explicitly specify
client: ElastiCacheClient
type annotation.
All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.
Client method usage example#
# ElastiCacheClient usage example with type annotations
from aiobotocore.session import get_session
from types_aiobotocore_elasticache.client import ElastiCacheClient
from types_aiobotocore_elasticache.type_defs import TagListMessageTypeDef
from types_aiobotocore_elasticache.type_defs import AddTagsToResourceMessageTypeDef
session = get_session()
async with session.create_client("elasticache") as client:
client: ElastiCacheClient
kwargs: AddTagsToResourceMessageTypeDef = {...}
result: TagListMessageTypeDef = await client.add_tags_to_resource(**kwargs)
Paginator usage example#
# DescribeCacheClustersPaginator usage example with type annotations
from aiobotocore.session import get_session
from types_aiobotocore_elasticache.client import ElastiCacheClient
from types_aiobotocore_elasticache.paginator import DescribeCacheClustersPaginator
from types_aiobotocore_elasticache.type_defs import CacheClusterMessageTypeDef
session = get_session()
async with session.create_client("elasticache") as client:
client: ElastiCacheClient
paginator: DescribeCacheClustersPaginator = client.get_paginator("describe_cache_clusters")
async for item in paginator.paginate(...):
item: CacheClusterMessageTypeDef
print(item)
Waiter usage example#
# CacheClusterAvailableWaiter usage example with type annotations
from aiobotocore.session import get_session
from types_aiobotocore_elasticache.client import ElastiCacheClient
from types_aiobotocore_elasticache.waiter import CacheClusterAvailableWaiter
session = get_session()
async with session.create_client("elasticache") as client:
client: ElastiCacheClient
waiter: CacheClusterAvailableWaiter = client.get_waiter("cache_cluster_available")
await waiter.wait(...)