TwitterUserCache

Documentation for eth_defi.feed.twitter_api.TwitterUserCache Python class.

class TwitterUserCache

Bases: object

File-backed cache of Twitter handle-to-user-ID mappings.

Stored at ~/.tradingstrategy/vaults/feeds/twitter-users.json.

Methods summary

__init__([path])

get(handle)

Look up a cached user entry by handle (case-insensitive).

get_all_user_ids()

Return a mapping of handle → user_id for all cached entries.

get_by_user_id(user_id)

Look up a cached user entry by numeric user ID.

is_stale(handle[, max_age_days])

Check whether a cache entry is missing or older than max_age_days.

put(handle, user_id, name)

Store or update a cache entry.

save()

Persist the cache to disk.

__init__(path=None)
Parameters

path (Optional[pathlib.Path]) –

get(handle)

Look up a cached user entry by handle (case-insensitive).

Parameters

handle (str) –

Return type

Optional[eth_defi.feed.twitter_api.CachedTwitterUser]

get_all_user_ids()

Return a mapping of handle → user_id for all cached entries.

Return type

dict[str, str]

get_by_user_id(user_id)

Look up a cached user entry by numeric user ID.

Parameters

user_id (str) –

Return type

Optional[eth_defi.feed.twitter_api.CachedTwitterUser]

is_stale(handle, max_age_days=30)

Check whether a cache entry is missing or older than max_age_days.

Parameters
  • handle (str) –

  • max_age_days (int) –

Return type

bool

put(handle, user_id, name)

Store or update a cache entry.

Parameters
  • handle (str) –

  • user_id (str) –

  • name (str) –

Return type

None

save()

Persist the cache to disk.

Return type

None