UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'g6USK41gchRgpIOKUwZPfKMl4Q3BxMFgx+52GtL4OaI='
WHERE
key_id = 'b583044fbed6df8c76dfd8482f33e7259af49b97c2ab56f0334a4d67a073adfc'
AND (
token = 'g6USK41gchRgpIOKUwZPfKMl4Q3BxMFgx+52GtL4OaI='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)