99 HyperGetResult ,
1010 IdResult ,
1111 ListOptions ,
12- OKIdResult ,
12+ OkIdResult ,
1313 QueryOptions ,
1414 Result ,
1515 SearchQueryOptions ,
@@ -209,11 +209,37 @@ async def add_cache():
209209 "year" : "1987" ,
210210 }
211211
212- result = await hyper .cache .add_async (
213- key = "movie-5000" , value = movie , ttl = "1w "
212+ result : Result = await hyper .cache .add_async (
213+ key = "movie-5000" , value = movie , ttl = "24h "
214214 )
215215 print ("hyper.cache.add_async result --> " , result )
216- # hyper.cache.add_async result --> {'ok': True, 'status': 201}
216+ # OkResult - hyper.cache.add result --> {'ok': True, 'status': 201}
217+ # NotOkResult - hyper.cache.add result --> {'ok': False, 'status': 409, 'msg': 'Document Conflict'}
218+
219+
220+ async def add_cache_thing ():
221+ thing : Dict = {"likes" : 100 }
222+
223+ result : Result = await hyper .cache .add_async (
224+ key = "thing-1" , value = thing , ttl = "1m"
225+ )
226+ print ("hyper.cache.add_async result --> " , result )
227+ # OkResult - hyper.cache.add result --> {'ok': True, 'status': 201}
228+ # NotOkResult - hyper.cache.add result --> {'ok': False, 'status': 409, 'msg': 'Document Conflict'}
229+
230+
231+ async def get_cache ():
232+ key = "movie-5000"
233+ result : HyperGetResult = await hyper .cache .get_async (key )
234+ print ("hyper.cache.get_async result --> " , result )
235+ # hyper.cache.get_async result --> {'_id': 'movie-5000', 'type': 'movie', 'title': 'Back to the Future 2', 'year': '1987', 'status': 200}
236+
237+
238+ async def get_cache_thing ():
239+ key : str = "thing-1"
240+ result : HyperGetResult = await hyper .cache .get_async (key )
241+ print ("hyper.cache.get_async result --> " , result )
242+ # hyper.cache.get_async result --> {'likes': 100, 'status': 200}
217243
218244
219245async def remove_cache ():
@@ -239,12 +265,12 @@ async def update_cache():
239265
240266
241267async def query_cache ():
242- result = await hyper .cache .query_async (pattern = "movie-500*" )
268+ result : HyperDocsResult = await hyper .cache .query_async (
269+ pattern = "movie-500*"
270+ )
243271 print ("hyper.cache.query_async result --> " , result )
244272 # hyper.cache.query_async result --> {'docs': [{'key': 'movie-5001', 'value': {'_id': 'movie-5001', 'type': 'movie', 'title': 'Back to the Future 3', 'year': '1989'}}, {'key': 'movie-5000', 'value': {'_id': 'movie-5000', 'type': 'movie', 'title': 'Back to the Future 2', 'year': '1988'}}], 'ok': True, 'status': 200}
245273
246- hyper .search .update (key , doc )
247-
248274
249275############################
250276#
0 commit comments