ohash icon indicating copy to clipboard operation
ohash copied to clipboard

Is there an equivalent method to objectHash in v1

Open bingtsingw opened this issue 5 months ago • 3 comments

Describe the feature

In v1, ojbectHash returns value like this: object:1:string:3:foo:string:3:bar, but in v2, serialize returns value like this: {foo:'bar'}

How can I generate return value in the form of version v1?

Additional information

  • [ ] Would you be willing to help implement this feature?

bingtsingw avatar Jul 18 '25 08:07 bingtsingw

We have reworked the serializer to rewrite it into a safer, more compact and faster format. Any reason you need the old format? (and in this case why not using v1?)

pi0 avatar Jul 18 '25 09:07 pi0

We have reworked the serializer to rewrite it into a safer, more compact and faster format. Any reason you need the old format? (and in this case why not using v1?)

In my old project, I used objectHash to generate a unique value and stored it in the database. When I tried to upgrade ohash, I found that v1 and v2 are incompatible, so I couldn't do the upgrade.

If v1 and v2 are incompatible, maybe we should highlight this change in the documentation. Currently, the documentation says that it is a renaming from objectHash to serialize.

bingtsingw avatar Jul 18 '25 10:07 bingtsingw

Sure feel free to make PR upsating docs!

I would suggest to use a format prefix when storing in db like v2:[hash] you can also save lots of space by upgrading new records!

pi0 avatar Jul 18 '25 10:07 pi0