UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'cPdK0hSHv/FBf64rHJNX+23TFvOa0Ze96GkuAG17Nzg='
WHERE
key_id = '965458b33c748890f3f4d2c0380c1c39c1b0de443af20563713be92ff820fcfe'
AND (
token = 'cPdK0hSHv/FBf64rHJNX+23TFvOa0Ze96GkuAG17Nzg='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)