Hopefully this is an easy one for someone. Basically I have a bunch of SQLite3Result objects that store cached data inside a class. I need to be able to reference this data when a method is called with the result as an argument. I thought it would be best to just keep the cache in an array where the key is a unique identifier for the result object.
So, is there anyway to get a unique indentifier for an object? Like the addressof() function in 'other' languages. 开发者_如何学GoI just need something so that when subsequent calls to a method with the result as an argument I can look up cached data based on that result.
Since your cached data is represented by your SQLite results, you could use their primary key identifiers as identifiers for your caches.
A PHP OOP-based alternative is spl_object_hash()
, but this creates a hash for every unique object even if multiple data objects are referenced by the same database row.
精彩评论