How to decode PHP serialized Redis response with Golang

huangapple go评论91阅读模式
英文:

How to decode PHP serialized Redis response with Golang

问题

我有一个关于我的 Redis 数据库的问题,它使用 PHP 序列化协议进行编码,但我不知道如何使用 Golang 解码这些数据,是否有类似于 JSON Unmarshal/Marshal 的方法可以实现这个功能?

英文:

I have a problem with my Redis db, it is encoded with PHP serialized protocol but I don't how I can decode this data using Golang, is there something like JSON Unmarshall/Marshall for this?

答案1

得分: 2

要在您的Go程序中读取此类数据,您将需要在Go中重新实现unserialize PHP函数。尽管我怀疑这是一项容易的任务。

更好的解决方案是使用一种便携式格式将数据存储在Redis中,例如JSON或Google Protobuf。

英文:

To read such data in your Go program you will have to reimplement unserialize PHP function in Go. I doubt it is an easy task though.

A better solution would be to use a portable format to store data in Redis, such as JSON or Google Protobuf.

答案2

得分: 0

我找到了这个链接:https://github.com/wulijun/go-php-serialize,我不知道你是否已经使用过它。

英文:

I found this https://github.com/wulijun/go-php-serialize i don't know if you already use it

答案3

得分: 0

只需在golang中重新实现php的serializeunserialize即可。

https://github.com/Trim21/go-phpserialize

英文:

Just reimplement php's serialize and unserialize in golang

https://github.com/Trim21/go-phpserialize

huangapple
  • 本文由 发表于 2015年10月8日 17:06:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/33011305.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定