UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Y4YrSuw2JWD92qBHjoJfQjW8osgZur8gCR1LXZUOAuQ='
WHERE
key_id = 'dbd2ad7398a11c7d1c87662d1226471f377c6abe34910db74f755ac8ebb70ae8'
AND (
token = 'Y4YrSuw2JWD92qBHjoJfQjW8osgZur8gCR1LXZUOAuQ='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)