transaction id

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

transaction id

Nick
Hi,

I want to generate a unique transaction id. I've considered a number of approaches:

1) Use Gemstone's shared counter functionality:

System _sharedCounterFetchValuesFrom: 23 to: 23. 
System _sharedCounter: 23 setValue: 10.
System _sharedCounter: 23 incrementBy: 1.

2) roll my own with a Mutex.
3) Use a UUID

I'm inclined to go with a UUID as there's no need to initialise it and it works across dialects, although I sacrifice readability.

Any thoughts?

Nick



 
Reply | Threaded
Open this post in threaded view
|

Re: transaction id

Jon Paynter-2
maybe something like this?
self transactionID: self asOop.


On Thu, May 5, 2011 at 10:25 AM, Nick Ager <[hidden email]> wrote:
Hi,

I want to generate a unique transaction id. I've considered a number of approaches:

1) Use Gemstone's shared counter functionality:

System _sharedCounterFetchValuesFrom: 23 to: 23. 
System _sharedCounter: 23 setValue: 10.
System _sharedCounter: 23 incrementBy: 1.

2) roll my own with a Mutex.
3) Use a UUID

I'm inclined to go with a UUID as there's no need to initialise it and it works across dialects, although I sacrifice readability.

Any thoughts?

Nick



 

Reply | Threaded
Open this post in threaded view
|

Re: transaction id

James Foster-8
In reply to this post by Nick
The disadvantage of sharedCounters is that they are not made persistent when the system is stopped and restarted. (Another disadvantage is that they are local to the host and not shared across multiple hosts--though the free license does not provide for multiple hosts so this is not a GLASS problem.)

I'd suggest you investigate the Persistent Counters method category in the System class. They are much like the sharedCounters, but persistent.

James

On May 5, 2011, at 10:25 AM, Nick Ager wrote:

> Hi,
>
> I want to generate a unique transaction id. I've considered a number of approaches:
>
> 1) Use Gemstone's shared counter functionality:
>
> System _sharedCounterFetchValuesFrom: 23 to: 23.
> System _sharedCounter: 23 setValue: 10.
> System _sharedCounter: 23 incrementBy: 1.
>
> 2) roll my own with a Mutex.
> 3) Use a UUID
>
> I'm inclined to go with a UUID as there's no need to initialise it and it works across dialects, although I sacrifice readability.
>
> Any thoughts?
>
> Nick
>
>
>
>  

Reply | Threaded
Open this post in threaded view
|

Re: transaction id

Thelliez
In the TFLogin library that I have been playing with recently, Tony
uses UUID.  I have not fully tested that but at first try it works in
GLASS.  Here is how an ID is generated (in class
TLAuthenticationManager)


generateRegId
        ^ UUID new primMakeUUID asString36.



Thierry
Reply | Threaded
Open this post in threaded view
|

Re: transaction id

Nick
Thanks for all the replies.

I think the easiest option for me is to use UUID as it's portable across Pharo and Gemstone.

@Thierry TLAuthenticationManager can be simplified as #primMakeUUID is called in the #initialise method, so the current method calls #primMakeUUID twice. The #generateRegId can be simplified to read:

generateRegId
     ^ UUID new asString36