UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'i8mHDIp1Lz12ClTVNcG+cRGb92SgZBysd0+prq/7Oy8='
WHERE
key_id = 'c87b267af9152ceee211b7e98456e9f1f7d88e487d6b4412f563ed8908d3fd76'
AND (
token = 'i8mHDIp1Lz12ClTVNcG+cRGb92SgZBysd0+prq/7Oy8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)