@@ -1333,38 +1333,6 @@ def dispatch(self, event_name: str, *args, **kwargs):
13331333 for event in self .extra_events .get (event_name , []):
13341334 asyncio .ensure_future (self ._run_event (event_name , event , * args , ** kwargs ), loop = self .loop )
13351335
1336- def default_cache (self , client ):
1337- """The default cache for :class:`EventsClient`.
1338-
1339- Because the whole 'events' notion hinges on comparing old values in cache to new values,
1340- **all cache objects have no expiry** and 1024 max size.
1341-
1342- .. note::
1343-
1344- If you choose to alter the cache to include an expiry, you will miss events due to integration of
1345- cache and events. The same applies to max size, although potentially missing events to trade for
1346- memory control may be important for some.
1347-
1348- """
1349- cache_search_clans ._is_clan = True
1350- cache_war_logs ._is_clan = True
1351-
1352- cache_current_wars ._is_war = True
1353- cache_clan_wars ._is_war = True
1354- cache_league_groups ._is_war = True
1355- cache_league_wars ._is_war = True
1356- cache_war_clans ._is_war = True
1357- cache_war_players ._is_war = True
1358-
1359- cache_search_players ._is_player = True
1360-
1361- cache_locations ._is_static = True
1362- cache_leagues ._is_static = True
1363- cache_seasons ._is_static = True
1364-
1365- for cache in self ._cache_lookup .values ():
1366- cache .clear (1024 , None )
1367-
13681336 def event (self , fctn , name = None ):
13691337 """A decorator or regular function that registers an event.
13701338
@@ -1614,17 +1582,19 @@ def start_updates(self, event_type='all'):
16141582
16151583 """
16161584 lookup = {
1617- 'clan' : self ._clan_update_event ,
1618- 'player' : self ._player_update_event ,
1619- 'war' : self ._war_update_event
1585+ 'clan' : [ self ._clan_update_event , [ cache_current_wars ]] ,
1586+ 'player' : [ self ._player_update_event , [ cache_search_players ]] ,
1587+ 'war' : [ self ._war_update_event , [ cache_current_wars , cache_clan_wars , cache_league_wars ]]
16201588 }
16211589 if event_type == 'all' :
16221590 events = lookup .values ()
16231591 else :
16241592 events = [lookup [event_type ]]
16251593
16261594 for e in events :
1627- e .set ()
1595+ e [0 ].set ()
1596+ for c in e [1 ]:
1597+ c .clear (1024 , None )
16281598
16291599 def stop_updates (self , event_type = 'all' ):
16301600 """Stops an, or all, events.
@@ -1649,17 +1619,19 @@ def stop_updates(self, event_type='all'):
16491619 """
16501620
16511621 lookup = {
1652- 'clan' : self ._clan_update_event ,
1653- 'player' : self ._player_update_event ,
1654- 'war' : self ._war_update_event
1622+ 'clan' : [ self ._clan_update_event , [ cache_current_wars ]] ,
1623+ 'player' : [ self ._player_update_event , [ cache_search_players ]] ,
1624+ 'war' : [ self ._war_update_event , [ cache_current_wars , cache_clan_wars , cache_league_wars ]]
16551625 }
16561626 if event_type == 'all' :
16571627 events = lookup .values ()
16581628 else :
16591629 events = [lookup [event_type ]]
16601630
16611631 for e in events :
1662- e .clear ()
1632+ e [0 ].clear ()
1633+ for c in e [1 ]:
1634+ c .clear (1024 , None )
16631635
16641636 def _dispatch_batch_updates (self , key_name ):
16651637 keys = cache_events .cache .keys ()
0 commit comments