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