2323 OP_CACHE_CLEAR_KEYS , OP_CACHE_REMOVE_KEY , OP_CACHE_REMOVE_IF_EQUALS , OP_CACHE_REMOVE_KEYS , OP_CACHE_REMOVE_ALL ,
2424 OP_CACHE_GET_SIZE , OP_CACHE_LOCAL_PEEK
2525)
26- from pyignite .datatypes import Map , Bool , Byte , Int , Long , AnyDataArray , AnyDataObject
26+ from pyignite .datatypes import Map , Bool , Byte , Int , Long , AnyDataArray , AnyDataObject , ByteArray
2727from pyignite .datatypes .base import IgniteDataType
28- from pyignite .datatypes .key_value import PeekModes
2928from pyignite .queries import Query , query_perform
3029from pyignite .utils import cache_id
3130
@@ -1128,7 +1127,7 @@ def __cache_remove_all(connection, cache, binary, query_id):
11281127 )
11291128
11301129
1131- def cache_get_size (connection : 'Connection' , cache : Union [str , int ], peek_modes : Union [int , list , tuple ] = 0 ,
1130+ def cache_get_size (connection : 'Connection' , cache : Union [str , int ], peek_modes : Union [int , list , tuple ] = None ,
11321131 binary : bool = False , query_id : Optional [int ] = None ) -> 'APIResult' :
11331132 """
11341133 Gets the number of entries in cache.
@@ -1137,7 +1136,7 @@ def cache_get_size(connection: 'Connection', cache: Union[str, int], peek_modes:
11371136 :param cache: name or ID of the cache,
11381137 :param peek_modes: (optional) limit count to near cache partition
11391138 (PeekModes.NEAR), primary cache (PeekModes.PRIMARY), or backup cache
1140- (PeekModes.BACKUP). Defaults to all cache partitions (PeekModes.ALL ),
1139+ (PeekModes.BACKUP). Defaults to pimary cache partitions (PeekModes.PRIMARY ),
11411140 :param binary: (optional) pass True to keep the value in binary form.
11421141 False by default,
11431142 :param query_id: (optional) a value generated by client and returned as-is
@@ -1151,21 +1150,23 @@ def cache_get_size(connection: 'Connection', cache: Union[str, int], peek_modes:
11511150
11521151
11531152async def cache_get_size_async (connection : 'AioConnection' , cache : Union [str , int ],
1154- peek_modes : Union [int , list , tuple ] = 0 , binary : bool = False ,
1153+ peek_modes : Union [int , list , tuple ] = None , binary : bool = False ,
11551154 query_id : Optional [int ] = None ) -> 'APIResult' :
11561155 return await __cache_get_size (connection , cache , peek_modes , binary , query_id )
11571156
11581157
11591158def __cache_get_size (connection , cache , peek_modes , binary , query_id ):
1160- if not isinstance (peek_modes , (list , tuple )):
1161- peek_modes = [peek_modes ] if peek_modes else []
1159+ if peek_modes is None :
1160+ peek_modes = []
1161+ elif not isinstance (peek_modes , (list , tuple )):
1162+ peek_modes = [peek_modes ]
11621163
11631164 query_struct = Query (
11641165 OP_CACHE_GET_SIZE ,
11651166 [
11661167 ('hash_code' , Int ),
11671168 ('flag' , Byte ),
1168- ('peek_modes' , PeekModes ),
1169+ ('peek_modes' , ByteArray ),
11691170 ],
11701171 query_id = query_id ,
11711172 )
@@ -1184,7 +1185,7 @@ def __cache_get_size(connection, cache, peek_modes, binary, query_id):
11841185
11851186
11861187def cache_local_peek (conn : 'Connection' , cache : Union [str , int ], key : Any , key_hint : 'IgniteDataType' = None ,
1187- peek_modes : Union [int , list , tuple ] = 0 , binary : bool = False ,
1188+ peek_modes : Union [int , list , tuple ] = None , binary : bool = False ,
11881189 query_id : Optional [int ] = None ) -> 'APIResult' :
11891190 """
11901191 Peeks at in-memory cached value using default optional peek mode.
@@ -1199,7 +1200,7 @@ def cache_local_peek(conn: 'Connection', cache: Union[str, int], key: Any, key_h
11991200 should be converted,
12001201 :param peek_modes: (optional) limit count to near cache partition
12011202 (PeekModes.NEAR), primary cache (PeekModes.PRIMARY), or backup cache
1202- (PeekModes.BACKUP). Defaults to all cache partitions (PeekModes.ALL ),
1203+ (PeekModes.BACKUP). Defaults to primary cache partitions (PeekModes.PRIMARY ),
12031204 :param binary: (optional) pass True to keep the value in binary form.
12041205 False by default,
12051206 :param query_id: (optional) a value generated by client and returned as-is
@@ -1213,24 +1214,27 @@ def cache_local_peek(conn: 'Connection', cache: Union[str, int], key: Any, key_h
12131214
12141215async def cache_local_peek_async (
12151216 conn : 'AioConnection' , cache : Union [str , int ], key : Any , key_hint : 'IgniteDataType' = None ,
1216- peek_modes : Union [int , list , tuple ] = 0 , binary : bool = False , query_id : Optional [int ] = None ) -> 'APIResult' :
1217+ peek_modes : Union [int , list , tuple ] = None , binary : bool = False ,
1218+ query_id : Optional [int ] = None ) -> 'APIResult' :
12171219 """
12181220 Async version of cache_local_peek.
12191221 """
12201222 return await __cache_local_peek (conn , cache , key , key_hint , peek_modes , binary , query_id )
12211223
12221224
12231225def __cache_local_peek (conn , cache , key , key_hint , peek_modes , binary , query_id ):
1224- if not isinstance (peek_modes , (list , tuple )):
1225- peek_modes = [peek_modes ] if peek_modes else []
1226+ if peek_modes is None :
1227+ peek_modes = []
1228+ elif not isinstance (peek_modes , (list , tuple )):
1229+ peek_modes = [peek_modes ]
12261230
12271231 query_struct = Query (
12281232 OP_CACHE_LOCAL_PEEK ,
12291233 [
12301234 ('hash_code' , Int ),
12311235 ('flag' , Byte ),
12321236 ('key' , key_hint or AnyDataObject ),
1233- ('peek_modes' , PeekModes ),
1237+ ('peek_modes' , ByteArray ),
12341238 ],
12351239 query_id = query_id ,
12361240 )
0 commit comments