UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'YLdZx2MkRkCgLpks+XuRf+aLHfXCFqYcg5lKmtE6Y7M='
WHERE
key_id = 'afd5a1663eec0b4bee50e81b316cb1a1844e5960f45b498c72ca441c57c15a84'
AND (
token = 'YLdZx2MkRkCgLpks+XuRf+aLHfXCFqYcg5lKmtE6Y7M='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)