UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'WGnT0TqqPcEr3aTRiF/X7lLBJeFv87cGAauXJGRk2x0='
WHERE
key_id = 'cad507cb77e2cb63dd15153c9cec825f0dc57a54d4d0a5e4e145a6b7c70ba727'
AND (
token = 'WGnT0TqqPcEr3aTRiF/X7lLBJeFv87cGAauXJGRk2x0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)