In Cassandra terminology, what is TimeUUID?

前端 未结 3 1835
挽巷
挽巷 2021-02-05 07:23

In Cassandra terminology, what is TimeUUID and when is it used?

3条回答
  •  有刺的猬
    2021-02-05 07:36

    TimeUUID is a random global unique identifier. 16 bytes.

    Sample hex presentation: a4a70900-24e1-11df-8924-001ff3591711

    See http://en.wikipedia.org/wiki/Universally_Unique_Identifier

    It may serve as a primary key in terms of relational database or when you need to store a list of values under some key.

    For example check this open source twitter example based on cassandra:

    http://twissandra.com/

    http://github.com/ericflo/twissandra

    User = {
        'a4a70900-24e1-11df-8924-001ff3591711': {
            'id': 'a4a70900-24e1-11df-8924-001ff3591711',
            'username': 'ericflo',
            'password': '****',
        },
    }
    
    Username = {
        'ericflo': {
            'id': 'a4a70900-24e1-11df-8924-001ff3591711',
        },
    }
    
    Friends = {
        'a4a70900-24e1-11df-8924-001ff3591711': {
            # friend id: timestamp of when the friendship was added
            '10cf667c-24e2-11df-8924-001ff3591711': '1267413962580791',
            '343d5db2-24e2-11df-8924-001ff3591711': '1267413990076949',
            '3f22b5f6-24e2-11df-8924-001ff3591711': '1267414008133277',
        },
    }
    

    Here user is assigned a unique key a4a70900-24e1-11df-8924-001ff3591711 which is used to refer to the user from other places.

提交回复
热议问题