UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'YZhfBd49aTlOFKqFtMp5fYZU2lF9zWxaWRwSZG+n/fE='
WHERE
key_id = 'a9d87b2b4c0ebcbb9152e8b64c2971e0a082f1225db06389275a54402edc4819'
AND (
token = 'YZhfBd49aTlOFKqFtMp5fYZU2lF9zWxaWRwSZG+n/fE='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)